Registering MSpec runners for TestDriven.NET on Windows x64

20 January 2010

EDIT: MSpec v0.3 now supports TestDriven.Net's v2.24 XCopy Deployable Test Runners.  So this blog post is legacy information at this time. 

td_rocket2[1] Machine.Specifications (MSpec) is my preferred Behavior-Driven Design (BDD) framework for Microsoft.NET.  Aaron Jensen, the author of MSpec, released support for TestDriven.NET, xUnit, nUnit, and Gallio.  And with the latest release of v0.3, it adds official support for ReSharper's Unit Tests and and Selenium integration testing.  Very cool stuff indeed, and a very active project!

What has bugged me a bit is getting TestDriven.NET to see my MSpec specifications, on my Windows 7 x64 platform.  Aaron so kindly includes a InstallTDNetRunner.bat file to register MSpec with TestDrive.NET; but, it only works on x86 systems.

So why does it not work with x64 systems?  It is because the installer for TestDriven.NET registers the runners in a different registry location.

Windows Vista/7 x64 (64-bit) MSpec runner TestDriven.NET registry file

Below, I have created a bat file you can copy and paste into your own InstallTDNetRunner-x64.bat if you are on Windows x64.  Or, you can download it from here:

http://eduncan911.com/blog/binary/legacy/InstallTDNetRunner-x64.zip



@echo off & if not "%ECHO%"=="" echo %ECHO%

setlocal
set LOCALDIR=%~dp0

echo Windows Registry Editor Version 5.00 > MSpecTDNet.reg
echo [HKEY_CURRENT_USER\Software\MutantDesign\TestDriven.NET\TestRunners\MSpec] >> MSpecTDNet.reg
echo "Application"="" >> MSpecTDNet.reg
echo "AssemblyPath"="%LOCALDIR:\=\\%Machine.Specifications.TDNetRunner.dll" >> MSpecTDNet.reg
echo "TargetFrameworkAssemblyName"="Machine.Specifications" >> MSpecTDNet.reg
echo "TypeName"="Machine.Specifications.TDNetRunner.SpecificationRunner" >> MSpecTDNet.reg
echo @="5" >> MSpecTDNet.reg
echo. >> MSpecTDNet.reg

echo [HKEY_LOCAL_MACHINE\SOFTWARE\MutantDesign\TestDriven.NET\TestRunners\MSpec] >> MSpecTDNet.reg
echo "Application"="" >> MSpecTDNet.reg
echo "AssemblyPath"="%LOCALDIR:\=\\%Machine.Specifications.TDNetRunner.dll" >> MSpecTDNet.reg
echo "TargetFrameworkAssemblyName"="Machine.Specifications" >> MSpecTDNet.reg
echo "TypeName"="Machine.Specifications.TDNetRunner.SpecificationRunner" >> MSpecTDNet.reg
echo @="5" >> MSpecTDNet.reg
echo. >> MSpecTDNet.reg

echo [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MutantDesign\TestDriven.NET\TestRunners\MSpec] >> MSpecTDNet.reg
echo "Application"="" >> MSpecTDNet.reg
echo "AssemblyPath"="%LOCALDIR:\=\\%Machine.Specifications.TDNetRunner.dll" >> MSpecTDNet.reg
echo "TargetFrameworkAssemblyName"="Machine.Specifications" >> MSpecTDNet.reg
echo "TypeName"="Machine.Specifications.TDNetRunner.SpecificationRunner" >> MSpecTDNet.reg
echo @="5" >> MSpecTDNet.reg

regedit MSpecTDNet.reg

del MSpecTDNet.reg


Setup TestDriven.NET and MSpec

Still a bit confused, getting TestDriven.NET and MSpec setup for the first time? Here's the steps to follow:

  • Go ahead and install TestDriven.NET.  It can be installed and upgraded at any time.
  • Next, grab the latest release of MSpec  and extract the zip to a semi-permanent location.  This is because things such as ReSharper and TestDriven.NET will need to know a common location for the mspec assemblies.  I recommend C:\Program Files (x86)\MSpec\.
    • Included with the MSpec zip is an InstallTDNetRunner.bat, but it only works on 32-bit Windows.  For 64-bit Windows, you want to copy my registry code above into a new file called InstallTDNetRunner-x64.bat.
    • Make sure to place this InstallTDNetRunner-x64.bat file in the same directory as your semi-permanent MSpec location above.
  • Finally, you want to double-click and execute the InstallTDNetRunner or InstallTDNetRunner-x64 from within this semi-permanent location.  This will insert the registry values for a new runner called MSpec for TestDriven.NET to detect and execute.

From this point further, you can right-click within different places to execute your specifications within your MSpec.  Some tips on locations you can right-click and execute the specs:

  • The project file: will execute all specs detected within that project.
  • The Namespace: will execute all specs detected within that namespace throughout the project.
  • Within the Establish context or Because of : Will execute all specs within that one class/scenario.
  • Within the It spec - Will execute just that one test.

Something to note is Aaron is currently upgrading MSpec (version 0.4, not released yet) to support TestDriven.NET's new 2.24 feature of version independent runners. I haven't looked completely into that myself, but should make registring TDNet runners in the future a bit easier.

 
Reader's Comments
 
ben said:
04 April 10 7:43 PM

I tried out your batch file for 64 bit win 7 and I'm  no longer getting

"The target type doesn't contain tests from a known test framework or a 'Main' method."

So I guess thats progress. However, now my simple sample spec output shows nothing but the

"------ Test started: Assembly: Sample.Tests.dll ------"

Below is a the test

[Subject("Creating an Organization")]

public class when_adding_an_item : to_empty_list_of_organizations

{

   It should_add_one_organization_to_the_list_of_organizations;

}

public abstract class to_empty_list_of_organizations

{

   protected static Organization org;

   Establish context = () =>

   {

       org = new Organization();

   };

}

Any ideas on how I could get TD.Net to show the "Not Implemented" message with MSpec.

I'm using xUnit 1.5 and TD.Net 2.24 and the MSpec from here:

http://teamcity.codebetter.com/guestAuth/repository/download/bt44/.lastSuccessful/Machine.Specifications-release.zip

I had previously run the normal InstallTDNetRunner.bat from another location before reading your post. I had also previously installed the TD.Net version 3 beta. But uninstalled and went back to 2.24.

Any hints would be appreciated.

Thanks,

Ben

 
07 May 10 9:10 AM

I had a dream to make my organization, however I did not earn enough amount of money to do it. Thank goodness my close colleague suggested to use the <a href="http://lowest-rate-loans.com/topics/business-loans">http://lowest-rate-loans.com</a>. So I took the short term loan and made real my desire.

Leave a Comment
Comment Policy: HTML is not allowed. Links and line breaks are converted automatically.
(required) 
(optional)
(required) 

 


  
Enter the anti-spam code you see above (required)

 

Comment Notifications
Subscribe to this post's comments using RSS

If you would like to receive an email when updates are made to this post, please register here