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

Notification

Icon
Error

NCrunch fails test on first run and then passes on second run
LKEthan
#1 Posted : Thursday, April 2, 2020 6:32:46 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2020(UTC)
Posts: 3
Location: United States of America

Hello,

I started using the trail version of NCrunch and its a fascinating tool. Although I have encountered the following oddity.

I have a test that generates a .bat file. The first time NCrunch is loaded that test always fails. With the following exception:
System.IO.DirectoryNotFoundException : Could not find a part of the path 'C:\Users\ethan.behar\AppData\Local\NCrunch\60016\2\XXXXXXXXXXX.Test\TestFiles\ActualOutput\XXXXXXXXXXX.bat'.

Once I run the test a second time it doesn't fail.

Now this occurs if I have tests running automatically or manually and if I restart visual studio or use the "Restart the Ncrunch engine, resynchronize with VS and rebuild all projects (reset)" button.
My first thought was that maybe Ncrunch is running the tests before the workspace location is fully created but if that was the case I would assume manually running the tests wouldn't cause the exception but it does.

Any insight into this problem is grealy appreciated.

-LKEthan
LKEthan
#2 Posted : Thursday, April 2, 2020 7:00:31 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2020(UTC)
Posts: 3
Location: United States of America

I already figured it out. This issue has to do with an empty folder in my test project. I use this folder to save my files generated by the tests. And then when the tests are over the files get deleted. It seems like NCrunch is getting confused on bringing this folder into the Ncrunch workspace.

Is there a way I can designated an empty folder with a flag or attribute so its always created in the Ncrunch workspace?

I'll check if the folder exists and create it if it doesn't.

-LKEthan
Remco
#3 Posted : Friday, April 3, 2020 12:52:07 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, thanks for sharing this problem.

Yes, we currently don't replicate empty directories into the workspace. This is a known issue.

I would recommend making a call to System.IO.Directory.CreateDirectory at the beginning of your test to ensure the directory containing the .bat file exists. This should make the test resilient and prevent any issues from arising.
LKEthan
#4 Posted : Friday, April 3, 2020 12:21:13 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2020(UTC)
Posts: 3
Location: United States of America

Thank you for the reply Remco.

I did indeed do as you suggested yesterday and the tests pass without issue now.

Out of curiosity, will Ncrunch replicate empty directories in the future?

-LKEthan
Remco
#5 Posted : Friday, April 3, 2020 11:04:38 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)
LKEthan;14575 wrote:

Out of curiosity, will Ncrunch replicate empty directories in the future?


I'd like to say yes, but this is one of those problems that is relatively low in impact (i.e. affects very few people) and takes a surprisingly high effort to solve.

So if we're to fix this, it may be some way off.
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.040 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download