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

Notification

Icon
Error

Testlocation with DeploymentItem inconsistent
Atreyu
#1 Posted : Friday, May 10, 2013 10:56:27 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/11/2013(UTC)
Posts: 11
Location: Netherlands

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
When running NCrunch using test-files on MSTest, the outcome is not consistent.
Almost always upon loading the solution, or starting NCrunch the unit tests that require deployed files fail.
Upon automated execution when a code change has been detected, they are successful.

I have applied deploymentitem attributes at class level as:
Code:
DeploymentItem("testfiles/details.pdf", "testfiles")


It seems to have to do with the location of the directory the testrunner uses, which is varying (maybe dependent on the last build performed, being tracked by NCrunch?)

It switches between (success):
Code:
[MyAppData]\Local\NCrunch\[SOMENUMBER]\[SOMENUMBER]\[NAMESPACE OF MY UNIT TEST LIBRARY]\bin\Out\
and (failure):
Code:
[MyAppData]\Local\NCrunch\[SOMENUMBER]\[SOMENUMBER]\TestResults\[SOMEGUID]\Out\


Some cases that some reproducible:
Code:
//Upon opening solution (FAILURE):
[MyAppData]\Local\NCrunch\10600\13\[NAMESPACE OF MY UNIT TEST LIBRARY]\bin\Out\testfiles\details.pdf

//Automated after trivial code change (SUCCESS):
[MyAppData]\Local\NCrunch\10600\13\TestResults\29fc99ad-5fd7-439f-83a8-8c2f68b04775\Out\testfiles\details.pdf

//After manual rebuild in NCrunch window (FAILS/SOMETIMES SUCCES)
[MyAppData]\Local\NCrunch\6584\30\[NAMESPACE OF MY UNIT TEST LIBRARY]\bin\Out\testfiles\details.pdf

//Manual execution in NCrunch (SUCCESS)
[code=csharp][MyAppData]\Local\NCrunch\6584\30\TestResults\5130ecf5-309b-4dfb-be30-9802f41eec8c\Out\testfiles\details.pdf


Within the failing tests' folder: [NAMESPACE OF MY UNIT TEST LIBRARY]\bin the deployed files are actually present at the compiler output folder but are somehow not copied to the 'Out' folder.
  • Debug
    • testfiles (containing testfiles)

  • In
    • [name of my machine] (empty)

  • Out (empty)


Any suggestions?
The 'deployment' option is switched on in my .testsettings file, but that should not matter, as NCrunch state it ignores these file altogether.
Remco
#2 Posted : Friday, May 10, 2013 12:31:48 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

The working directory of the testing process will definitely vary according to the workspace being used, but the intended behaviour is such that it should be consistent in regards to the TestResults directory or bin\out - so this definitely looks like a defect.

Which version of MSTest are you using? (i.e. are you working with VS2010 or VS2012?), also, are you using any other test frameworks alongside MSTest?

Is there any chance you can share a sample of a test that can cause this erratic behaviour? Does checking the Directory.GetCurrentDirectory also exhibit erratic results?


Thanks!

Remco
Atreyu
#3 Posted : Friday, May 10, 2013 1:04:03 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/11/2013(UTC)
Posts: 11
Location: Netherlands

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
I'm working with MSTest of VS2012, update 2
(located at: %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe)

I also have Resharper installed, which installs and runs NUnit I believe. When disabling Resharper, the issue remains.

First I thought that maybe Directory.GetCurrentDirectory was the culprit, so I removed it.
Now it seems that the behaviour of Directory.GetCurrentDirectory is consistent with previous mentioned issue:

When failing it states:
[MyAppData]\Local\NCrunch\[SOMENUMBER]\[SOMENUMBER]\[NAMESPACE OF MY UNIT TEST LIBRARY]\bin\Out

When succeeding it states:
[MyAppData]\Local\NCrunch\[SOMENUMBER]\[SOMENUMBER]\TestResults\[SOMEGUID]\Out

Let me see if I can make a copy of my project and strip it
Atreyu
#4 Posted : Friday, May 10, 2013 2:17:09 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/11/2013(UTC)
Posts: 11
Location: Netherlands

Thanks: 3 times
Was thanked: 1 time(s) in 1 post(s)
I just stripped, cleaned, enhanced the readability and zipped my project:

NCrunch.zip

Unfortunately, I now only had the issue once, en then further I could not reproduce it. *sigh*
Remco
#5 Posted : Saturday, May 11, 2013 1:52:45 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks! I'll take a look and see if I can figure it out. Perhaps if I shake it in the right way, I can reproduce the issue :)

Cheers,

Remco
mlevin
#6 Posted : Friday, May 24, 2013 9:20:49 PM(UTC)
Rank: Newbie

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

Was there any resolution here? I'm having the same issue. Ncrunch is consistently running in C:\Users\Matt\AppData\Local\NCrunch\37708\45\Tests\CommunicationServiceTests\bin\Debug (or similar), but DeploymentItem files don't get copied as they are with MsTest. Both Directory.GetCurrentDirectory and AppDomain.CurrentDomain.BaseDirectory give me the above directory.

Thanks,

Matt
mlevin
#7 Posted : Friday, May 24, 2013 9:24:29 PM(UTC)
Rank: Newbie

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

I should mention that the files are not referenced in my solution (but are stored in tfs in a directory) and I am using a post build task to copy the files to my build directory.
Remco
#8 Posted : Saturday, May 25, 2013 1:30:24 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Matt -

If you're experiencing consistent behaviour in this situation, it's quite likely your experiencing a different problem.

Make sure that you've made NCrunch aware of the files that need to be copied by adding them to the additional files to include configuration setting. You'll also need to enable the run post build event configuration setting so that your build step can copy the files.

Are you making use of any other test frameworks alongside MSTest? (i.e. Xunit, NUnit, etc)
mlevin
#9 Posted : Tuesday, May 28, 2013 2:55:13 PM(UTC)
Rank: Newbie

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

Yes, you are right. Sorry, didn't see that in the documentation.

Thanks,

Matt
CourtJesterBob
#10 Posted : Friday, February 20, 2015 1:52:48 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/2/2012(UTC)
Posts: 13
Location: Beachwood, OH

I am now having this issue consistently in my solution. I have several tests marked with a [DeploymentItem(@'TestData\Status.xml")]. When I open the solution or choose to Resynchronise, rebuild, and rerun all tests, all of them fail telling me they cannot find the file located at ...\UnitTests\bin\out\Status.xml. I can see the file in ...\UnitTests\Status.xml as well as ...\Debug\TestData\Status.xml. When I run the failing test one at a time, they all succeed.

To further complicate the issue, I have two different test projects that make use of deployment items. One project works like a champ and never has any issues, and the other is the one above that is broken.

Bob
Remco
#11 Posted : Friday, February 20, 2015 9:46:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Bob,

DeploymentItems are a bit of a complex mess with MSTest, as their behaviour tends to be slightly different depending upon the version of MSTest being used and how this is configured. Because NCrunch doesn't rely on testsettings files, it must infer the correct usage of this attribute and how to apply it during the test run. For this reason, I usually try to advise people avoid them and to instead reference the files relatively as they exist in the project in their pre-copied location.

Considering the behaviour around the copying seems inconsistent, I'm wondering if it may be possible that the DeploymentItems are making your tests sequence dependent. This can happen if you have one test without a deployment item (or an incorrectly specified deployment item) that is relying on the same file being copied using the deployment item of another test. This means the former test cannot run without failure until the latter test has been executed.

Something that can be helpful is to examine the full state of the workspace NCrunch has constructed for your project after it has been built, then again after tests have been executed. You can do this by right-clicking on the project file (or any tests within it), then choosing Advanced->Browse to workspace. This will let you easily examine which files exist in the workspace and which aren't there. This can also be a way to identify files that haven't been copied into the workspace by NCrunch and need to be added to the 'Additional files to include' setting.
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.069 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download