開発
2013/1/15
D言語でBDD
mima
あけましておめでとうございます。
さっそくですが、D言語でBDDフレームワークを作ってみました。
dspecs
1ファイル構成のライブラリなので、適当にダウンロードしてインポートして使ってください。
こんな感じでBDDできます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | unittest { static struct Hoge { bool match = true ; string str = "abc" ; } static struct Piyo { int i; this ( int i) { this .i = i * i; } } "abc" .should | { "start with a" .by | { assert ( "abc" .startsWith( "a" )); }; "end with c" .by | { assert ( "abc" .endsWith( "c" )); }; }; "initial instance of Hoge" .should | { Hoge hoge; "match" .by | { assert (hoge.match); }; "have member str which is abc" .by | { assert (hoge.str == "abc" ); }; }; "Piyo(10).i" .は | { "100である" .べき | { assert (Piyo(10).i == 100); }; "101でない" .べき | { assert (Piyo(10).i != 101); }; }; } |
日本語でも大丈夫です。
このライブラリの詳しい解説などは、Codelogyで行う予定です。
担当:美馬(UFCSが素晴らしい)