Based on the -When-Then example with NUnit

Can someone point me some resources for the Give-When-Then style using NUnit?

+6
c # nunit bdd
source share
3 answers

If you download and add a link to StoryQ , you can use a good BDD style (see examples by clicking the link) and at the same time use NUnit as usual (and TestDriven.Net, R # runner, or whatever you have).

+4
source share

This When Then style is closely related to the Assert Act Assert style for unit testing.

Here is an example:

[Test] public void RotateAngle_Given27Degress_Returns64Degrees() { //Arrange or Given var someAngleClass = new Angle(); //Act or When var result = someAngleClass.Rotate(27); //Assert or Then Assert.That(result, Is.EqualTo(64)); } 

The great thing about this testing style is that you donโ€™t need to see the underlying code to understand the intent of the behavior.

For more information, see several sites:

http://www.arrangeactassert.com/

Roy Osherov Blog

http://www.artofunittesting.com/

+6
source share

I know this is an old question, but if you haven't done it yet, you should check out SpecFlow . This allows you to write the specification in plain text in a function file. The tool will automatically generate NUnit tests based on a function file.

+5
source share

All Articles