Bug 4031 - Cannot run NUnit tests when referenced assemblies have dependencies
Summary: Cannot run NUnit tests when referenced assemblies have dependencies
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NUnit ()
Version: unspecified
Hardware: PC Mac OS
: --- major
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2012-03-22 11:31 UTC by Alan McGovern
Modified: 2017-08-22 21:43 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Alan McGovern 2012-03-22 11:31:41 UTC
I have created a project called MonoDevelop.MacDev.Tests. This assembly only references the MonoDevelop.MacDe. I am writing tests purely for types defined in that project.

When i try to run the nunit tests I have designed, i end up in a situation where the tests will not run unless I manually copy all dependencies of MonoDevelop.MacDev to the same directory as MonoDevelop.MacDev.Tests.dll. This should be automatic.
Comment 1 Mikayla Hutchinson [MSFT] 2012-03-22 12:45:31 UTC
How should the NUnit addin know what assemblies to load, and from where, and in a way that doesn't conflict with your assembly loading requirements?

Your test setup needs to local-copy the assemblies, or use the addin engine to load the assemblies.
Comment 2 Alan McGovern 2012-03-22 13:00:46 UTC
Which assemblies do I need to local copy? The only one MonoDevelop.MacDev.Tests depends on is MonoDevelop.MacDev. Am i supposed to guess every single assembly that might be required and add an explicit local-copy reference to it to MonoDevelop.MacDev.Tests? I don't know how visual studio handles this situation. Does it have the same issue?
Comment 3 Alan McGovern 2012-03-22 13:33:14 UTC
The reason I mention this is that currently if I do not copy all dependencies locally i get an obscure error message telling me that a type that definitely exists in an assembly which is definitely there could not be loaded:


The reason why the type could not be loaded is because MonoMac.dll was not copied locally. This needs to be reflected in the error message for someone to be able to fix the problem
Comment 4 Mikayla Hutchinson [MSFT] 2012-03-22 13:57:11 UTC
One more clarification on the original issue, for reference:

VS does behave like MD. NUnit shouldn't second-guess how you expect your assemblies to be loaded, it should use the standard runtime loaders, or it may break tests, so it can't dynamically load the assemblies. And MD *does* transitively local-copy references of references etc, but only if those references are themselves local copy. If they're not, then copying them would be wrong - the program is obviously expecting them to be loaded some other way.

This is why all references are local copy by default, to keep things simple :)
Comment 5 Rodrigo Kumpera 2014-01-17 18:01:47 UTC
This bug is wrongly classified.
Comment 6 Will Smith 2017-08-22 21:43:49 UTC
Thanks so much for taking the time to submit this report! I attempted to reproduce this issue based on the bug description with the latest Visual Studio 2017 for Mac Preview version 7.2, and I was unable to hit the problem. If this issue is still occurring for you, please reopen this report and attach a reproduction, ideally starting with a new template project and then adding just the code necessary to demonstrate the issue.