Archive

Posts Tagged ‘unit test’

How to use TestDox to help with TDD / BDD

February 28, 2010 Leave a comment

As a senior developer, team lead or even a product owner you might find yourself wondering if a developer has really understood what they need to build before they really get stuck into the coding.

Even if you’re The Lone Developer it pays to clearly see your test classes and methods (especially if they represent the stories, scenarios and acceptance criteria) in a clean, readable format so that you can do a quick sanity check before you get your head down and code, code, code.

Capture the stories, write your test cases, run TestDox and review your understanding!

Download TestDox and give it a try!

How to use TestDox to review existing unit test code

February 28, 2010 Leave a comment

So you find yourself faced with a mass of code to review (or maybe you’ve inherited it) and fortunately someone found the time to write a suite of unit tests within the code base.

Do you fire up Visual Studio and trawl through the code to see what’s there?

TestDox can help out here. Just point TestDox at your unit test assemblies and it will generate a concise, readable report detailing all the unit test classes and methods that it finds.

Download TestDox and give it a try!

Unit Test frameworks supported by TestDox

February 28, 2010 Leave a comment

With most automated unit testing frameworks, attributes are placed in the source code at the class and method level when writing the unit tests.

TestDox’s support for unit testing frameworks is based on the use of attributes which are read using good old .NET reflection. When executed, TestDox reflects assemblies and looks for attributes with certain names on classes and methods.

TestDox’s default unit testing framework support

Out of the box, TestDox supports MSTest and Nunit but can easily support any other attribute based testing framework by specifying command line arguments.

TestDox’s default attribute names for test classes are:

  • TestClass (or TestClassAttribute)
  • TestFixture (or TestFixtureAttribute)

TestDox’s default attribute names for test methods are:

  • TestMethod (or TestMethodAttribute)
  • Test (or TestAttribute)

Supporting other unit testing frameworks in TestDox

TestDox can be easily configured to look for other test attributes from the command line.

To do this, just use the command line arguments /class and /method to specify the attribute class names that TestDox should look for in your unit test assemblies.

For example:

TestDox /class:MyTestClassAttribute /method:MyTestMethodAttribute

See help for more details

Guidelines for naming unit tests for TestDox analysis

February 28, 2010 Leave a comment

TestDox produces output based on the unit test classes and test methods it finds in your project’s assemblies.

As such, you can improve the TestDox output by naming your test classes and methods in a way that emphasises the expected behaviour or the intention of the code being tested.

If you’re following a test driven or behaviour driven development approach then you’re probably doing this anyway!

Note that these are just suggestions and are not required.

Test Classes

When naming test classes, make it clear what the trigger for the set of tests is.
i.e. the “When” in the story/scenario.
e.g. When_an_analysis_session_completes

Test Methods

When naming test methods, make it clear what should or shouldn’t happen in the scenario the test method represents.
i.e. the “Then” in the story/scenario.
e.g. it_should_output_how_many_test_methods_were_found