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

Notification

Icon
Error

Referenced files not copied over, causing tests to fail.
ChrisMcLean
#1 Posted : Tuesday, April 29, 2014 2:22:15 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/8/2013(UTC)
Posts: 3
Location: United States of America

Thanks: 1 times
Right now in one C# library we have an xml file in the project. It is set to copy always in that project.

We have a test which uses that lib, and in the test's debug directory, there is a folder schema, and a file in that folder bob.xml that we are using to hold some info that is used in the library. The tests run fine in msft's test runner.

But nCrunch reports the test failing

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Chris\AppData\Local\NCrunch\119428\15\ScoreMessageTests\bin\Debug\Schema\bob.xml'.

Does anyone know of any workarounds?
Remco
#2 Posted : Tuesday, April 29, 2014 11:43:57 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 Chris,

I'm sure we can find a way to make this work. What is the origin of the bob.xml file? My assumption is that this is being sourced from somewhere else in your solution and that it is copied to the bin\Debug\Schema directory at build time. Is this correct?
1 user thanked Remco for this useful post.
ChrisMcLean on 4/30/2014(UTC)
ChrisMcLean
#3 Posted : Wednesday, April 30, 2014 12:30:56 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/8/2013(UTC)
Posts: 3
Location: United States of America

Thanks: 1 times
Yes. In the Lib project there is a folder schema, and in that folder we've got bob.xml, set to always copy. In MSBuild this results in the Debug directory looking like:
\Debug
lib.dll
lib.pdb
etc...
\Schema\
bob.xml

The rational behind this was that we're eventually going to have bob1.xml, and bob2.xml, and just stick 'em in a folder so they don't get in the way.

In MSTest, when we reference the Lib project, we get the same folder structure in it's Debug directory, so the test runs fine.

Remco
#4 Posted : Wednesday, April 30, 2014 2:00:29 AM(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)
Right. Because bob.xml is a direct dependency of the Lib project and not of the Test project, it's probably not being copied because of the limited scope of the 'Copy referenced assemblies to workspace' configuration setting. When you enable this setting, it will only apply to the project that you've enabled it for. Probably in this case we need to be a bit broader with where we specify it.

For the sake of narrowing things down, if you enable the 'Copy referenced assemblies to workspace' configuration setting for ALL the projects in your solution (use the multi-select option in the configuration window), does this solve the problem?

If at all possible, it may be worth looking at ways in which this file is referenced. If you're able to introduce an abstraction that lets you find the file at its source location (instead of the copied location) when the test is executed with NCrunch, this means you won't need to make use of the 'Copy referenced assemblies to workspace' setting and the engine will work much faster.
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.038 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download