I am a big fan of the xUnit.NET framework; I get this light, simple, clean and detail.
Now we say that I have such a class:
public class AdditionSpecification {static integer result; Public Zero because () {Results = 2 + 2; } Public Zero Result_is_non_zero () {Assert.True (Results <1>;); } Public Zero Result_is_correct () {Assert.Equal (4, result); }}
With the test class above I want to see xUnit.NET 2 test cases and run the first () method of each of them.
With the name of your class or method, except for any issue, the structure of this test / specification, xUnit.NET framework, or BDD, this is my question:
< P> How can i tell xUnit.NET how do I optimize the test of this class without class using a custom [fact] attribute on each goal testing method? Want to recognize and execute methods?I know that I can get it from BeforeAfterAttribute and before decorating each test method with custom after execution. How can I do this at class level? Do I have to write a custom runner? Xuinit.net's iUseFixture allows you to do this for each stable setup. Therefore you can define your stability class:
Public class AdditionFixture: IDisposable {public int () {2 + 2; } Public Zero Extracting () {// Trial Code Torn In}}
Your test class can then implement it (setFixture is required to be applied):
Additional Public Category: IUseFixture & lt; Extra & gt; {Good result; Public Zero SetFixture (AdditionFixture Stability) {Results = Stability. Because (); } [Facts] Public Zero Result_is_non_zero () {Assert.True (Results 0); } [Facts] Public Zero Result_is_correct () {Assert.Equal (4, Results); }}
The Exotic Runner will make an example of your stability, and pass it in SetFixture before running each trial. After running all of their tests, the runner will again settle the stability if he applies IDisposable. I hope that helps!
The codeplex has more information in the xUnit wiki, which is a good example of implementing iUseFixture in which you can manage the management of a database connection for you.
Comments
Post a Comment