are you familiar with behavior driven development? the high points are that each work item’s acceptance criteria should be executable, and that at least these ‘acceptance tests’ should be written using a ubiquitous language co-crafted by development and product. the general idea is something like:
+Scenario 1: Account is in credit+
Given the account is in credit
And the card is valid
And the dispenser contains cash
When the customer requests cash
Then ensure the account is debited
And ensure cash is dispensed
And ensure the card is returned
breaking that down a little, you are describing a scenario, and the rest of the prose describes what makes up that scenario. each ‘given’ builds up a context that the ‘when’ statement is executed inside of. each ‘then’ statement is an expected behavior. if you’re wanting more detail i’d suggest a read through Dan North’s blog.
as a .net developer there some really great tools for test driven development. tools like resharper, ncrunch, nunit, and the list could go on for miles. there are also some very neat tools for bdd like specflow. there’s always been a catch though: test runners like nunit are much too focused on the outcome rather than the behavior, and tools like specflow are hard to use unless you have a really awesome BA/Product Owner. to alleviate what i see as a gap in tooling i’ve created what i hope will one day be a comprehensive, test runner agnostic bdd framework for .net. its called Given, and this is what it looks like:
given is currently has wrappers for both nunit (seen above), and mstest(example project). the syntax is almost entirely the same, and i’ve done my darnedest to get to feature parity between nunit and mstest despite microsoft’s best efforts. the main goal here is readability. you could pretty much hand the results of these tests to a product owner at the end of the sprint to show that all of their acceptance criteria had been met and were being tested, if only you could somehow export the results…
Given has a built in reporting engine, and the default output uses t4 templating to export your test results to an html file. the interface that the report engine uses is public, and can be overridden by your test project simply by having an implementation present. you’d rather the output be xml or json or a pdf? have at it. i’d love a pull request when you’re done so i can integrate it as an option in the core.
using Given is as easy as installing the right variant as a nuget package. for nunit use
For mstest use
so that pretty much covers the basics. there is obviously a lot of nuance left out of this post, and i’d suggest that you take a look at the example projects on github for a little more depth. thanks for taking a look!