views:

53

answers:

1

I'm beginning to get the grips of BDD and MSpec, but I'm still really bugged by the fact that I'm unable to debug my tests/specs, and that I have to leave the IDE to go to a html report file to see the results.

Currently, I have a post build event configured to run mspec.exe $(TargetFileName) --html “$(ProjectDir)Report.html”, but there must be some better way to do this.

Does anyone know any good add-ins, test runners or whatever that will let me

  1. debug tests, instead of just running them
  2. show the test results in a nice way inside Visual Studio

(Footnote: I'm running VS2010 Professional on Windows 7, if that matters.)

A: 

There are basically three options you have:

  1. You can set up a custom tool in Tools | External Tools to start mspec.exe with the current project's assembly to run the contexts and generate the HTML report.

  2. Install TestDriven.Net and ensure that Machine.Specifications.dll.tdnet and Machine.Specifications.TDNetRunner.dll are in your project's copy of MSpec. You can then run and debug your contexts from the context menu: "Run Tests", "Run With | Debugger" without further installation.

    There's an example of what the MSpec folder looks like for all of my projects.

  3. If you use ReSharper 4.1, 4.5, 5.0 or the latest 5.1 EAP (== beta) there are runners for each of these versions.

    The ZIP download contains batch files that install the runner for each respective version of ReSharper. ReSharper's unit test support is pretty extensive in terms of UI widgets/shortcut support, the reporting tree view and debugging.

    If you're a dotTrace user you can also profile right from within Visual Studio. dotCover (another JetBrains product) allows you to calcualate code coverage results from your MSpec runs.

    On top of that, you get all the nice coding and navigation features that ReSharper provides.

Be aware that only the first option will generate the HTML report as both the TestDriven.Net and ReSharper runners do not support HTML report generation. From my point of view this isn't an issue since the TD.Net and ReSharper runners offer fairly complete reporting mechanisms through the Visual Studio UI.

Another option that might work (I haven't used it myself) is to leverage the Gallio support that MSpec has. Gallio is a runner/framework for several testing frameworks; it might as well support debug runs with MSpec. Contact @smaclell if you have questions about Gallio support.

Alexander Groß
Thanks! I currently am using approach 1, but I'm not too happy with having to switch to firefox to view the report all the time. I already have both TestDriven.NET and ReSharper installed, but the only output I'm getting inside VS is in form of plain text in the output window. Call me demanding, but I'd like little green and red icons in a list of specs grouped in expanding/collapsing subject groups :P Is there a way to achieve that? If so, what do I click?
Tomas Lycken
No, there is no way to display HTML reports after TD.Net or ReSharper tests runs. Both tools do not have the necessary extensibility points to make that happen.I wonder why you need to display HTML, though. What's the advantage over say, ReSharper's Unit Test window that displays red/green icons for contexts?Regarding [Subject] groups in ReSharper: This is doable, but it will require a code change in the ReSharper runner (plus, an option to enable that feature). We accept patches ;-)
Alexander Groß