Build/Test Issues

Issue with Sharepoint Integration Tests

Started by AndrewSwerlick on 8,765 views

I've just started playing with ncrunch and really like the setup. I'm having a little trouble with my integration tests that go against the SharePoint 2010 server object model. In SharePoint development, you have to instantiate the site object using the code

using(SPSite site = new SPSite(<siteUrl>)
{
//code to execute against site goes here.
}

In Nunit itself these tests run fine, but in the ncrunch runner they all fail with a "System.IO.FileNotFoundException" with the Inner Exception message of "The Web application at <serverUrl> cannot 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." The failure happens at the line where I'm creating the new SPSite object.

What's very interesting is that this issue same issue actually crops up when trying to access the SharePoint2010 server object model in MSTest, unless you have VS SP1 and you make sure your test project targets .NET 3.5. This is a well known and well documented issue, so I wonder if there's a similar root cause here. Below are a few links on the MSTest issue.

The problem described
https://www.nothingbutsharepoint.com/sites/devwiki/SP2010Dev/Pages/Unit%20Testing%20with%20SharePoint%202010%20Development.aspx

The fix
http://sharepoint.bg/radi/post/Unit-Testing-SharePoint-2010-with-MSTest.aspx

Edited

Interesting. I have a feeling this may be happening because at the moment NCrunch always runs the tests inside a 32-bit process, which according to the articles you've quoted sounds like it would be a problem for sharepoint.

If you haven't already, would you be able to send through a bug report using the NCrunch menu right after the test fails? This will send through a log file containing details about the process it's failing in so I can take a closer look.

Also, thanks for reporting the issue.
Remco,

Running inside a 32 bit process definitely sounds like the likely culprit. SharePoint 2010 is big on the whole 64 bit thing.

Anyways, I submitted the bug report so you should see that soon. Thanks for taking an interest. I've got all my unit tests in ncrunch and I'm loving the interface. It's a fantastic piece of software.
Thanks again. I'll have a look at the report and will see what I can do.

Post a reply

Log in to reply.