donghyun-you / UniTest

Simple Unity3D BDD/TDD Framework
0 stars 1 forks source link

Assertion for BDD #4

Open donghyun-you opened 8 years ago

donghyun-you commented 8 years ago

for example these styles of assertions are required

as a C# attributed classes/methods as a barista I want a coffie so that drip ristretto

"Ready for roasted beans".ShouldBe("grind",()=>true).Then("drip",()=>true).Done("in 15 sec"()=>true); "If you gotta beans burned, it".ShouldBe("failure"()=>false);

as a C# attributed classes/methods when drip ristretto

"it".ShouldBe("hot"()=>true);

... (conditions could be a method etc)

donghyun-you commented 8 years ago

change design BDD starts from Scenario("whatever").ShoudBe(blabla)....Done(); Done() notify something test on their own class (TestNode).

"Done" do not require any parameter. more considerations about belows.

"When" (for react some test succeeded). "Then" (what's the diffrent of the ShouldBe? simply concatenating the report strings?)

donghyun-you commented 8 years ago

remove "Scenario" on TestFlow. and add "AssertAbout/AssertIf", "WarnAbout/WarnIf", "CommentAbout/CommentIf" instead on a9e5ed7cefe79f571f7fd4aed782076dc1b69d3f

make assertion chaining style defines like as belows

"SomeSubject".Chaining.Chaining...Conclude();

Subject = how assert the method chain. Chaning = add messages exact chained Negation Chaning = "Not" is the (currently) unique negation chanin. it add the negation message and reverse the negation flag. Conclusion = assert or notify to parent test class how it done. if Subject start with AssertAbout or AssertIf. the method chain will throw ScenarioFailureException others(Warn,Comment) will just notify the message and do not stop the test flow.

this implementation inspiered from Should.js but not exactly same implementation.

donghyun-you commented 8 years ago

example of method chanining

AssertIf("some topic",10-1).Should.Be.GreaterThan(1);
AssertAbout(10-1).Should.Be.GreaterThan(2);
CommentAbout(10-1).Should.Be.GreaterThan(100); // it will not stop the routine
AssertAbout(10-1).Should.Be.GreaterThan(100); // it will stop the routine