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

Notification

Icon
Error

Reflection Exception when running tests.
Luciferius
#1 Posted : Thursday, February 28, 2013 12:34:38 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

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

I tried to use NCrunch because I love Infinittest for eclipse. After I got every project to compile I tried to run my tests.
The task runner process status is Completed. The status of the underlying tests are Running but they dont do anything.
If I select the task runner process in the Processing Queue I get the follwoing stacktrace:

[13:23:42.6842-TestExecutionTask-8] ERROR (Internal): System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at nCrunch.Reflection.Clr.ClrAssembly.get_Types()
at nCrunch.Reflection.ReflectedAssembly.GetFlattenedTypes()
at nCrunch.Reflection.ReflectedAssembly.#=qs2_oOiBUxtZn_gNpwZ8iPjLn5lAzQnCfWjDv6p9neNo=()
at nCrunch.Reflection.ReflectedAssembly.GetTypeByFullName(String typeFullName)
at nCrunch.TestExecution.ReflectionExtensions.GetTypeFromTestId(ReflectedAssembly assembly, TestId testId)
at nCrunch.TestExecution.ReflectionExtensions.GetMemberFromTestId(ReflectedAssembly assembly, TestId testId)
at #=qWONS4dr5w7Ki0$RiwFRZLyaxminPjbGL5IYxHL89jJ7ZI41J5YVgb9ONwhKoDpOJNYXcpEWszCBvYCWvsb_UBg==.#=qZTcArX2yt6MJZ31mPCphz7KLnAMfHnFMuK9c2DIi0nY=(TestId[] #=qKXVbb_5NuAC1Z3nCC5Bkip8HgucklnT_bkFE71LalTg=, ReflectedAssembly #=qGg3$aFHongBPz3n12k$pfg==)
at #=qWONS4dr5w7Ki0$RiwFRZLyaxminPjbGL5IYxHL89jJ7ZI41J5YVgb9ONwhKoDpOJNYXcpEWszCBvYCWvsb_UBg==..ctor(MSTestNames #=qC7coe4UERCd_o8_lPmGFLQ==, String #=qkiMhFI3aZJmZVGx03g5KGXlvMfvyYrzn4MS1eaYrpMM=, String #=qQ0uEy9kDhxK99QDj5aCfye4jCAUnUnjGGbaWGSzK2W4=, ReflectedAssembly #=qjvhYLIqIO$BHkxdxeAB39Q==, TestId[] #=qNN5tg_ov5x01svRfOvqQwZgNXMbo$cw94gR6a0ZR2Dc=)
at nCrunch.TestExecution.Frameworks.MSTest.MSTestFramework.RunTests(TestOutput output, TestExecutionMapSet testMapSet, TestExecutionParameters parameters)
at nCrunch.TestExecution.TestRunnerThread.#=q7v3LnBjYuJV_NJz$Mxoi$Q==()


Has anyone an idea what this could meanß

Regards, Luciferius
Remco
#2 Posted : Thursday, February 28, 2013 9:03:15 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, thanks for posting and for taking the time to try out NCrunch!

There is something unusual with one of the fixture types in your test project that is causing runtime reflection to fail to resolve the type. Are you able to narrow down which class is causing the problem? I'd really like to see a bit more about how the class is declared so we can identify what is unique about it. The task in the processing queue that failed should also contain the list of tests that it was trying to execute, so you may be able to figure out which fixture is causing the problem by deductively trying to run the tests in the task individually (using the 'run tests' option in the Tests Window or by right-clicking on the test declaration).
Luciferius
#3 Posted : Friday, March 1, 2013 8:44:33 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Thanks for the response. I found the problem, but not the solution.

Our assemblies are local delay signed with a public key and on the build server they get correctly signed. Following problem: if I deactivate the signing in NCrunch with "Prevent from signing" the unit tests work, but only after another problematic change.
The unit tests are in a different assembly than the code. Because of that these two assemblies are friendly with "InternalsVisibleTo". There I have to put the public key so that the unit tests can be run after the assemblies are signed. Unfortunate this does not wok for unsigned. There I have to delete the public key. But than the unit tests are not working on the build server. So I can only make them work on Ncrunch OR the build server.
On this point I need a solution for the problem.

Regards, Luciferius.
Remco
#4 Posted : Friday, March 1, 2013 8:52:36 AM(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)
Nice work on identifying the cause of the problem. This is an easy one to solve - you simply need to introduce some conditional logic so that you use a different [InternalsVisibleTo] attribute when working with NCrunch, as opposed to the build server. You can make use of the #if NCRUNCH directive to achieve this. For example:

#if NCRUNCH
[assembly: InternalsVisibleTo ("TestProject.Tests")]
#else
[assembly: InternalsVisibleTo ("TestProject.Tests, PublicKey=mypublickey")]
#endif
1 user thanked Remco for this useful post.
Luciferius on 3/1/2013(UTC)
Luciferius
#5 Posted : Friday, March 1, 2013 11:34:38 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Great thanks, that does the trick for me.

Regards, Luciferius
1 user thanked Luciferius for this useful post.
Remco on 3/1/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.039 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download