Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NCrunch failing to build MVC Integration Test sample
idarroch
#1 Posted : Tuesday, July 24, 2012 10:45:58 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/24/2012(UTC)
Posts: 4
Location: Auckland

I am trying to use NCrunch with Steve Sanderson's demo project for MVC Integration Testing. His post about it is here:
Steve Sanderson's Post
and the download of the project is here:
Sample Project Download

My problem is that the solution builds and tests OK from within Visual Studio, but I get the following error when trying to run NCrunch over it:

SetUp : System.InvalidOperationException : Could not load MvcIntegrationTestFramework.dll within a bin directory under C:\Users\idarroch\AppData\Local\NCrunch\13932\29\MyMvcApplication. Is this the path to your ASP.NET MVC application, and have you set up a post-build event to copy your test assemblies and their dependencies to this folder? See the demo project for an example.
at MvcIntegrationTestFramework.Hosting.AppHost..ctor(String appPhysicalDirectory, String virtualDirectory) in C:\Development\MVC\Downloaded Samples\IntegrationTesting\MvcIntegrationTestFramework\Hosting\AppHost.cs:line 31#0
at MvcIntegrationTestFramework.Hosting.AppHost..ctor(String appPhysicalDirectory) in C:\Development\MVC\Downloaded Samples\IntegrationTesting\MvcIntegrationTestFramework\Hosting\AppHost.cs:line 21#1
at MyMvcApplication.Tests.HomeControllerTests..ctor() in C:\Development\MVC\Downloaded Samples\IntegrationTesting\MyMvcApplication.Tests\HomeControllerTests.cs:line 15#2

The test is erroring on the following line:
appDomainProxy = (AppDomainProxy) ApplicationHost.CreateApplicationHost(typeof (AppDomainProxy), virtualDirectory, appPhysicalDirectory);
where virtualDirectory = "/", and appPhysicalDirectory has been set to: Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\..\\MyMvcApplication")

It appears I need to get NCrunch to copy the whole MyMVCApplication folder into its test location. Is there a better way to do this to reduce performance issues?

Once I get the demo project working with NCrunch, I want to apply those lessons to my own integration test project, which is failing for the same reason.

Thanks
Remco
#2 Posted : Wednesday, July 25, 2012 11:42:37 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,143

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting! Great to see NCrunch building up adoption in Auckland.

Essentially your test project has what I like to call an 'Implicit' reference to the contents of your web project. NCrunch treats each project as a completely separate unit to be built and tested independently, so these sorts of references usually require a bit of additional configuration before they'll work correctly.

You can find more information about the behaviour of NCrunch's workspacing in the wiki. Essentially you need to make sure your web project is included as a resource of your tests project using the 'Additional files to include' project-level configuration option (i.e. "..\MyWebProject\**.*").

From what you've described, it also sounds as though you may be making use of a build event in order to copy the web project files into your testing project. By default, NCrunch will disable pre/post build events. If you require these for your integration tests, make sure you set the build events to run as part of your NCrunch configuration for your testing project.

Something to be aware of is that by making use of the output binaries in the build output directory of your web project, you won't be using the binaries that NCrunch builds continuously for this web project - so you'll need to rebuild manually before changes to your web backing code are picked up by the tests in NCrunch. The only way to work around this would be to build your own test environment using DLLs that are output from the NCrunch build process, by copying these DLLs into the Web project's build output directory inside the workspace during your test execution and prior to the webserver being initialised. There is an example on how to identify the DLLs NCrunch is using in its test environment in the troubleshooting test issues page under 'Assumptions About Referenced Assembly Locations'.

This may sound quite complex, and it is. Right now you are essentially building an artificial testing environment with its own custom-built test process, which will be tightly coupled with the arrangement of your source code in your normal solution directory. NCrunch completely rearranges the solution directory structure inside its workspaces, so making these tests run perfectly without a manual build step will require a bit of understanding about how NCrunch works. I hope that the wiki should provide you with the information you need to make this work, but please let me know if you need more information so that I can update it where necessary. NCrunch itself had similar problems when testing against itself, and after some attention I did manage to get it working very well.


I hope this helps!


Cheers,

Remco
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download