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

Notification

Icon
Error

NCrunch doesn't run xUnit.net 1.9.2 tests
TeaDrivenDev
#1 Posted : Sunday, September 29, 2013 1:19:43 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/29/2013(UTC)
Posts: 2
Location: Germany

As mentioned on Twitter the other day, NCrunch cannot run xUnit.net tests using xUnit versions higher than 1.9.1. This is apparently because of the fact that it specifically uses v1.9.1 assemblies internally. If I try to run tests with xUnit v1.9.2 (that run fine in ReSharper, and if make them reference 1.9.1 also run in NCrunch), the "NCrunch Tests" window shows the following:

This test was not executed during a planned execution run. Ensure your test project is stable and does not contain issues in initialisation/teardown fixtures.


As I've been having lots of issues regarding assembly versioning in unit tests in recent times (not related to NCrunch), this was quite clearly another one. I fired up the Assembly Binding Log Viewer and logged one attempt to run the tests for a project in NCrunch. Of the resulting entries, three are more or less explicitly related to xUnit (at the end of this post).

For some reason NCrunch tries to use xUnit 1.9.1 although I don't have that in my project. I looked in the NCrunch folder mentioned in one of the error messages, and indeed there were the 1.9.1 DLLs in that. I tried the most naive approach to rectifying this - just replace the DLLs with the 1.9.2 ones, and sure enough that did the trick. I re-ran all the tests in NCrunch, and they turned green.

This worked until I restarted Visual Studio. Then the tests weren't just failing, but the test projects weren't building anymore in NCrunch. I looked again in the NCrunch folder and found Gallio.XunitAdapterLatest.gallioplugin that still referenced build 1.9.1.1600. I changed these references to 1.9.2.1705 (the current stable version), but that didn't help either. When selecting one of the failing projects, the NCrunch window shows the following:


Gallio.Model.ModelException: An exception occurred while invoking a test driver. ---> System.IO.FileNotFoundException: Could not load file or assembly 'xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The system cannot find the file specified.
at Gallio.XunitAdapter.Model.XunitTestExplorer.TryGetTypeTest(ITypeInfo type, Test assemblyTest)
at Gallio.XunitAdapter.Model.XunitTestExplorer.GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, Boolean populateRecursively)
at Gallio.XunitAdapter.Model.XunitTestExplorer.ExploreImpl(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
at Gallio.Model.Helpers.TestExplorer.Explore(IReflectionPolicy reflectionPolicy, ICodeElementInfo codeElement)
at Gallio.Model.Helpers.SimpleTestDriver.GenerateTestModel(IReflectionPolicy reflectionPolicy, IEnumerable`1 codeElements, IMessageSink messageSink)
at Gallio.Model.Helpers.SimpleTestDriver.DescribeImpl(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Describe(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.<>c__DisplayClass17.<DescribeImpl>b__15(ITestDriver driver, IList`1 items, Int32 driverCount)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.ForEachDriver[T](MultiMap`2 testFrameworkPartitions, Func`4 func)
--- End of inner exception stack trace ---
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.ForEachDriver[T](MultiMap`2 testFrameworkPartitions, Func`4 func)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.DescribeImpl(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Describe(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at nCrunch.TestExecution.Frameworks.Gallio.GallioWrapper.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, String assemblyFilePath, String[] referencedAssemblyFilePaths)
at nCrunch.TestExecution.Frameworks.Gallio.GallioTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, String assemblyFilePath, String[] referencedAssemblyFilePaths)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, String assemblyFilePath, String[] referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.DiscoverTests(TestFrameworkDescription[] applicableTestFrameworks)
at nCrunch.Compiler.RemoteBuildRunner.#=qJ_9$8x3p6Jd4bNnhWtW9r735mP$qMOEaOFvFdjhVkSY=(ComponentBuildParameters #=q4BIPIjcvARj25O_xzNvNOQ==, String #=qBsfAvxV6Q9z2WQfszeaUsN9MGIbMJQ5D9TVrLVUxtpg=, BuildOutput #=q0067Mw2tcQb2sLmbabLmPw==, String #=qhkclUc_$7XweEbsIN3P9rVmGg2AxBnN8b$x_4Hr9RUY=, String[] #=qVOb4lovNzligrv42nkg7YKwr6TWNADF7yF4Fj9NWwCw=)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)


So apparently, there's still a hard dependency on xUnit 1.9.1 somewhere within NCrunch that prevents it to work with newer builds than that one specific version.


I am using NCrunch 1.47.0.18 (the issue already existed before 1.47) with VS 2012.


As mentioned, here are the assembly binding error logs that refer to xUnit:


*** Assembly Binder Log Entry (27.09.2013 @ 16:38:08) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\nCrunch.TestHost.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = GCN\atriesch
LOG: DisplayName = Gallio.XunitAdapterLatest
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Gallio.XunitAdapterLatest | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = nCrunch.TestRunner_797721c61d884f34910a1989b1d52272
Calling assembly : Gallio, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\atriesch\AppData\Local\NCrunch\4236\62\Plugins\FriendlyConcatenatedValues.Tests\bin\Debug\GlobalConcepts.Dvb.Plugins.FriendlyConcatenatedValues.Tests.dll.config.ncrunchconfig
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/Gallio.XunitAdapterLatest.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/Gallio.XunitAdapterLatest/Gallio.XunitAdapterLatest.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/Gallio.XunitAdapterLatest.EXE.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/Gallio.XunitAdapterLatest/Gallio.XunitAdapterLatest.EXE.
LOG: All probing URLs attempted and failed.


*** Assembly Binder Log Entry (27.09.2013 @ 16:38:08) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\nCrunch.TestHost.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = GCN\atriesch
LOG: Where-ref bind. Location = C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\Xunit\Latest\xunit.dll
LOG: Appbase = file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = nCrunch.TestRunner_797721c61d884f34910a1989b1d52272
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\atriesch\AppData\Local\NCrunch\4236\62\Plugins\FriendlyConcatenatedValues.Tests\bin\Debug\GlobalConcepts.Dvb.Plugins.FriendlyConcatenatedValues.Tests.dll.config.ncrunchconfig
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Remco Software/NCrunch for Visual Studio 2012/Xunit/Latest/xunit.dll.
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\Xunit\Latest\xunit.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
LOG: Re-apply policy for where-ref bind.
LOG: Redirect found in application configuration file: 1.9.1.1600 redirected to 1.9.2.1705.
LOG: Post-policy reference: xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
LOG: Switch from LoadFrom context to default context.
LOG: Using application configuration file: C:\Users\atriesch\AppData\Local\NCrunch\4236\62\Plugins\FriendlyConcatenatedValues.Tests\bin\Debug\GlobalConcepts.Dvb.Plugins.FriendlyConcatenatedValues.Tests.dll.config.ncrunchconfig
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.9.1.1600 redirected to 1.9.2.1705.
LOG: Post-policy reference: xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
LOG: GAC Lookup was unsuccessful.
LOG: The post-policy assembly reference requires probing again.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit/xunit.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit.EXE.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit/xunit.EXE.
LOG: All probing URLs attempted and failed.


*** Assembly Binder Log Entry (27.09.2013 @ 16:38:08) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\nCrunch.TestHost.x86.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = GCN\atriesch
LOG: DisplayName = xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
(Fully-specified)
LOG: Appbase = file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = nCrunch.TestRunner_797721c61d884f34910a1989b1d52272
Calling assembly : Gallio.XunitAdapterLatest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\atriesch\AppData\Local\NCrunch\4236\62\Plugins\FriendlyConcatenatedValues.Tests\bin\Debug\GlobalConcepts.Dvb.Plugins.FriendlyConcatenatedValues.Tests.dll.config.ncrunchconfig
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.9.1.1600 redirected to 1.9.2.1705.
LOG: Post-policy reference: xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit/xunit.DLL.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit.EXE.
LOG: Attempting download of new URL file:///C:/Users/atriesch/AppData/Local/NCrunch/4236/62/Plugins/FriendlyConcatenatedValues.Tests/bin/Debug/xunit/xunit.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Remco Software/NCrunch for Visual Studio 2012/Xunit/Latest/xunit.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2012\Xunit\Latest\xunit.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Remco Software/NCrunch for Visual Studio 2012/Xunit/Latest/xunit/xunit.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Remco Software/NCrunch for Visual Studio 2012/Xunit/Latest/xunit.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/Extensions/Remco Software/NCrunch for Visual Studio 2012/Xunit/Latest/xunit/xunit.EXE.
LOG: All probing URLs attempted and failed.


Let me know if there's any other information I can provide.
Remco
#2 Posted : Sunday, September 29, 2013 2:45:06 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue, and for taking the time to put together so much information about it.

As you've perhaps speculated by looking through the plugin config files, NCrunch's integration with xUnit (via Gallio) works by using assembly binding redirections. This means that if NCrunch identifies your project as making use of xUnit, it will direct it to use xUnit 1.9.1 at runtime regardless of which version of xUnit is referenced.

The binding redirection works by taking the version coded into the .gallioplugin file and injecting this in the task runner's app.config file when building the test environment. So in theory, what you've done (changing the gallioplugin file and the xUnit binaries) should be enough to redirect to the new version, but this configuration was never designed to be changed in a deployed build of NCrunch, so I cannot give any assurance that it would work reliably. Generally to change the packaged version of a test framework will require a new build of NCrunch specifically designed and tested with the new framework version.

I've just done some testing here with xUnit 1.9.2, and it seems to be functioning normally with NCrunch. I'm wondering if you might be able to provide me with some more information about the failure pattern of NCrunch with xUnit 1.9.2 without having made any modifications to the NCrunch deployed binaries or config files:

- Can you submit a bug report directly after the failure has appeared? The log file may be able to give more information about why the failure is appearing.
- If you set your 'Log verbosity' (global configuration option) to 'Detailed', then try running any of the tests, do you see any useful information appear in the processing queue for the related test task?
- If you set up a small dummy project with a single test that references xUnit 1.9.2, does this project work for you?
- Have you tried using NCrunch with xUnit 1.9.2 on any other solution?


Thanks!

Remco
TeaDrivenDev
#3 Posted : Monday, September 30, 2013 10:43:31 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/29/2013(UTC)
Posts: 2
Location: Germany

I have just sent a bug report right after manually running a set of failing xUnit 1.9.2 tests. The log message in NCrunch stays the same with the log verbosity set to "Detailed".

Since you said you found it to be working correctly with xUnit 1.9.2, I have done a little more experimenting and found something rather odd - and along the way got it working.

I always handle xUnit via NuGet, and for sending the bug report, I only updated a single project in the solution to 1.9.2 - and it worked. I looked at the app.config and packages.config and found nothing suspicious. I then updated xUnit for all test projects in the solution and got 4 out of 7 failing - but unlike earlier attempts, three were now working. Between the working and non-working ones, I found one difference in the app.config files: The non-working ones have a binding redirect to xUnit 1.9.2, the working ones *don't*. Even more peculiar is that *all* of them have redirects to xunit.extensions 1.9.2 which doesn't appear to bother NCrunch at all.

So the concrete problem that NCrunch has appears to be with the binding redirect to xUnit (and xUnit only), and causing it is (once again) NuGet with its ever-creative way of handling binding redirects in app.config. That means I do have a workaround now that is a bit easier than always making sure I only work with xUnit 1.9.1.


A question on the side - why does NCrunch bring its own xUnit assemblies at all? I always expected it to simply use the assemblies referenced in the test project. Or is that not possible just because of that assembly versioning thing?
Remco
#4 Posted : Monday, September 30, 2013 11:24:21 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
This makes really good sense now. So Nuget is adding the binding redirections in order to ensure that you're using the right version of xUnit when you run tests. NCrunch adds its own binding redirection to the .config file too, so the CLR must be randomly choosing which redirection to use at run time. Removing the 1.9.2 redirections should get rid of the problem entirely. I've logged a task to tough up NCrunch's binding redirection logic so that it will remove existing redirections that may clash with its own.

NCrunch is piggy-backing off Gallio in order to integrate with xUnit. Gallio's integration strategy is to package its own version of xUnit and statically link to this at compile and run time. Because xUnit.dll includes both the test runner code AND the framework attributes, you're absolutely correct that it's possible to dynamically link with this binary and simply use the version provided with the code under test ... However, this would mean taking a very different (and somewhat more complex) integration approach inside the test adapter.

NCrunch's xUnit support is due for a major overall, and I've been waiting for the release of xUnit 2.0 before doing this, as xUnit 2.0 includes a complete rewrite of the test runner API. My early observations of xUnit 2.0 indicate that it will have separate binaries for the test runner API and the framework attributes, which would make any dynamic integration with xUnit 2.0 impossible - i.e. NCrunch would still need to package its own version. I've suggested to the authors to include both the API and framework attributes inside the same binary to avoid the need for this ... hopefully it's a direction they'll look into taking. Otherwise a new version of NCrunch will be required before anyone can make use of features in any new xUnit release.
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.140 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download