url: http://cs.gogo-asp.net/blogs/naoki/archive/2012/04/17/SpecFlow-_6830_-WatiN-_92302952287557305F30_-BDD-_6E30966E9950_.aspx
snippet:
-----引用-----
BDD は Behavior Driven Development の略で、振る舞いを決めた上で開発を進める手法(スペックファースト)の事です。
SpecFlow や WatiN などがこの代表的なツールです。SpecFlow は Visual Studio 内での仕様の作成と実施をサポートし、WatiN はブラウザーを使用して、エンド ツー エンドの自動システム テストを実行できるようにします。
サンプルコード
using NSpec;
class describe_specifications : nspec
{
void when_creating_specifications()
{
//some of these specifications are meant to fail so you can see what the output looks like
it["true should be false"] = () => true.should_be_false();
it["enumerable should be empty"] = () => new int[] { }.should_be_empty();
it["enumerable should contain 1"] = () => new[] { 1 }.should_contain(1);
it["enumerable should not contain 1"] = () => new[] { 1 }.should_not_contain(1);
it["1 should be 2"] = () => 1.should_be(2);
it["1 should be 1"] = () => 1.should_be(1);
it["1 should not be 1"] = () => 1.should_not_be(1);
it["1 should not be 2"] = () => 1.should_not_be(2);
it["\"\" should not be null"] = () => "".should_not_be_null();
it["some object should not be null"] = () => someObject.should_not_be_null();
//EXPERIMENTAL - specify only takes a lambda and does
//its best to make a sentence out of the code. YMMV.
specify = ()=> "ninja".should_not_be("pirate");
}
object someObject = null;
}
サンプルスペック出力
describe specifications
when creating specifications
true should be false - FAILED - Expected: False, But was: True
enumerable should be empty
enumerable should contain 1
enumerable should not contain 1 - FAILED - Expected: not collection containing 1, But was:...
1 should be 2 - FAILED - Expected: 2, But was: 1
1 should be 1
1 should not be 1 - FAILED - Expected: not 1, But was: 1
1 should not be 2
"" should not be null
some object should not be null - FAILED - Expected: not null, But was: null
ninja should not be pirate
-----引用-----
0 件のコメント:
コメントを投稿