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

Notification

Icon
Error

Behavior around unused references different from MSTest
jnijni
#1 Posted : Monday, April 8, 2013 4:57:05 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/18/2012(UTC)
Posts: 6
Location: Canada

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
Hi,

We hit a weird issue this morning where our test was running fine under nCrunch, but would fait with resharper or mstest. It turned out that a required DLL that is referenced in the project was copied over by nCrunch, but not mstest.

This dll is referenced in our project, but is never used directly. It is only used in the app.config to drive unity (yes, we'll leave the xml-based config of unity soon enough). MSTest sees the reference, but sees no use of it (no "using" i assume); therefore it won't copy it over. It's optimization... i guess.

While I agree this is a bad behavior on mstest's part, it would be nice if nCrunch would warn you about it so that our CI runs fine.

Here is an example (we use unity, but let's make it simpler) :

In a test project, add a reference to an other project in you solution (let's call those A.Tests and A).

Now, in a test class in A.Tests, do something like :
Code:
Activator.CreateInstance("A", "A.Namepsace.AClass");


However, never directly call a class in A, never import it or anything. If you only indirectly use the classes in A, MSTest will "optimize" things and remove A from the output folder. Activator will then try to find it and you will get an ugly error of type System.IO.FileNotFoundException. I would have pasted the output here, but it's all in french so I guess this is useless.

Here are some guys (girls too, maybe) who had the same issue : http://stackoverflow.com...enced-project-libraries

Hope this is clear!

Thanks,
Jni
Remco
#2 Posted : Monday, April 8, 2013 10:20:17 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi Jni,

Thanks for sharing this issue. I can see how the behaviour of NCrunch in this situation could lead to builds failing, and a warning would be a useful thing to have.

Because of the way the NCrunch test environment is built, I have a feeling that it will be very challenging to implement anything that could issue a reliable warning in this sort of situation, but I'll have a bit of a think about ways this might be done.


Cheers,

Remco
jnijni
#3 Posted : Tuesday, April 9, 2013 1:18:31 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/18/2012(UTC)
Posts: 6
Location: Canada

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
Hi,

This is what I expected, it is indeed hard to mimic this behavior. However, I would look over to mstest's code (if it's open source - otherwise you would need to poke around) to see how they do it, maybe it's just a simple "grep (imports|using) <namespace>" and it would be easy to reproduce this. If they really build a dependency tree, this might get tricky though.

In any case, if you implement this in a "dumb" way, it is still better than nothing. A warning that says "MAYBE you will have trouble, try it with the mstest runner" would be better than nothing I think. Even though you don't always get it right, it would still help.

Thanks again,
Jni
1 user thanked jnijni for this useful post.
Remco on 4/10/2013(UTC)
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.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download