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

Notification

Icon
Error

DeploymentItem test passes in VS and Resharper, fails in NCrunch
jkcarter
#1 Posted : Wednesday, November 5, 2014 2:04:58 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/19/2014(UTC)
Posts: 1
Location: United States of America

I filed a bug report for this already, but I'll post here in case anyone else has the same issue and wants to chime in.

Here's a project demonstrating the issue:
https://github.com/jason.../NCrunch-DeploymentItem

Instructions

  • Pull the repository
  • Open DeploymentItemProject.sln using Visual Studio 2010, 2012, or 2013
  • Build the DeploymentItemTest project.
  • Enable NCrunch and do not ignore any test projects (if it's not already enabled)
  • Notice that the one test fails
  • Open the Test->Test Explorer (VS 2012/13) or Test->Windows->Test View (VS 2010) windows.
  • Run the one test and notice that it passes.
  • If you have Resharper installed, run the test with its test runner as well, and notice that it passes.

It seems as if NCrunch has a problem with files from referenced projects that are marked in the Properties panel (F4) as Copy to Output Directory equal to either "Copy if newer", or "Copy always". If the file isn't in the test project's .*proj file, NCrunch doesn't see it.

The only workaround I've found that is effective is the following.

Workaround

  • Right click the Unit Test project in Solution Explorer
  • Select Add->Existing Item
  • In the lower right, select All Files (*.*) from the dropdown
  • Navigate to the DeploymentItem file(s) and select it/them
  • Expand the dropdown on the Add button and select Add as Link
  • In Solution Explorer, select the files you just added
  • Open the properties panel (F4)
  • Set the Copy to Output Directory option to either "Copy if newer" or "Copy always"
Remco
#2 Posted : Wednesday, November 5, 2014 9:29:20 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for posting this issue. I really appreciate you taking the time to submit the sample solution as this always make analysis of such issues much easier.

Although this may be a surprise, this behaviour is actually by design. NCrunch uses a build optimisation that allows it to build projects individually, outside of the normal VS build chain. In order for this to work, NCrunch isn't able to copy dependencies upwards into referencing projects because doing this requires a rebuild of every referencing project, then every project referencing these projects (thus completely invalidating the optimisation).

When experiencing problems with this behaviour, people usually observe it through assembly referencing issues, but it does also apply to files marked to be copied to the build output directory. The documentation is geared more towards helping people identify/resolve assembly referencing issues rather than the one you've reported, which perhaps might need to be revised - http://www.ncrunch.net/documentation/considerations-and-constraints_assembly-colocation-assumptions.

Anyway, to turn off the build optimisation that is causing this problem, just set the Copy referenced assemblies to workspace NCrunch project-level configuration setting on the test project to 'True'.
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.033 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download