Wednesday, October 14, 2009

Unit testing SharePoint WSS 3.0 x64 bit

trying to MS unit test code on x64 bit OS with x64 bit WSS 3.0 installed

public void TestMethod1()
using (SPSite sp = new SPSite("http://localhost:13000/"))
"Site valid");

Error Message
Test method TestProject1.UnitTest1.TestMethod1 threw exception:

System.IO.FileNotFoundException: The Web application at http://localhost:13000/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add
a new request URL mapping to the intended application..

download nunit (only 32 bit). Nunit will automatically choose which JIT compiler to use to test the code.

Additional Stuff
Code modification to have both nunit and MS test running together

#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Category = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute;
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestContext = System.Object;