Running unit tests

Feb 22, 2011 at 2:59 AM

I'm interested in running the unit tests but can't seem to figure out how.

I installed the latest version of Mole (0.94). Ran the Build SharePoint option

Open the solution (with tests) and built the solution successfully.

Next I open the xUnit GUI and tried to open the Microsoft.Practices.SharePoint.Common.Tests.dll

- The first time it complained about xUnit.dll not being in the folder. I copied it to the Debug folder where the Microsoft.Practices.SharePoint.Common.Tests.dll

- Now when I open the .Tests.dll it complains that it cannot load the Moles framework (it's looking for version 0.93.0.0 but I have 0.94 installed)

 

---------------------------xUnit.net Test Runner---------------------------

Error loading assembly: Could not load file or assembly 'Microsoft.Moles.Framework, Version=0.93.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

---------------------------   ---------------------------

 

Any help is appreciated. Thanks.

Coordinator
Feb 22, 2011 at 1:30 PM

If you open up the solution with unit tests, there will be a unit testing project that runs the moles based tests with Visual Studio.  Use this one instead.

Feb 22, 2011 at 10:56 PM

Finally got it working by deleting all the .moles related files and the .moles references. I then added the Moles reference for each of the four assemblies (right click on the original assembly under References and select Add Moles Reference). This made the .dlls regenerate for the new Moles version.

 

Ah and yes ckeyser thanks for the tip on running the unit tests through Visual Studio itself. I wasn't aware that it was possible for xUnit tests.

Coordinator
Feb 22, 2011 at 11:03 PM

that can be a little confusing, the unit tests use the visual studio testing framework.  We used x-Unit for integration tests.  SharePoint requires 3.5 framework and doesn't let the 4.0 framework run, and visual studio unit test will only run with 4.0 - the end result, if you aren't using moles to define a substitute implemention and the tests are calling into SharePoint, then you need xUnit.

Feb 23, 2011 at 1:53 AM

That makes sense. Thanks for the support!