Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to resolve assembly for base type of TestFixture if placed in a different dll #147

Closed
initram opened this issue Mar 17, 2017 · 14 comments
Assignees
Milestone

Comments

@initram
Copy link

initram commented Mar 17, 2017

We have a set of classes that are used as base classes for several TestFixtures in many different projects, so they have been placed in their own project and compile to a separate dll (that is placed next to the assembly containing our TestFixture).

When I try to run my unit tests Mono.Cecil fails to load the assembly containing the base class. After debugging the issue it seems that the working directory is not set correctly when trying to resolve the base type of a TestFixture class. I managed to fix my issue by setting the working directory before trying to resolve a base class.

I Changed NavigationDataProvider.cs:56 from
typeDef = typeDef.BaseType.Resolve();
to
var tmp = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(Path.GetDirectoryName(typeDef.Module.FullyQualifiedName)); typeDef = typeDef.BaseType.Resolve(); Directory.SetCurrentDirectory(tmp); // be a good citizen and reset path to what it was before.

I do not really like this way of solving the problem, but I do not know the codebase well enough to come up with a proper fix for this.

If you want me to create a pull request with my changes or create a reproduction solution, then let me know.

@CharliePoole
Copy link
Member

  1. What version of the adapter are you using?

  2. Where is the base fixture assembly WRT the original test assembly?

  3. Is the problem only with locating the source code (as your change would suggest) or is the test not found in discovery and/or execution? To put it differently, exactly what symptoms do you see.

@initram
Copy link
Author

initram commented Mar 17, 2017

I was using latest extension available for vs2017. But was also seeing the issue when building from source (master)

The two assemblies are side by side in the output directory of the test assembly project.

I could see the tests in the test explorer but was unable to run them. When trying to run the test the output was that it could not load my test assembly due to missing dependency.

@CharliePoole
Copy link
Member

Just to confirm: you are using the NUnit (2) VS Adapter and not the NUnit 3 VS Adapter, right?

@initram
Copy link
Author

initram commented Mar 17, 2017

That is correct and also the latest nunit 2 release to go with it.

@OsirisTerje
Copy link
Member

See comment on #143 , contains a zip file with nuget and vsix with a beta fix

@initram
Copy link
Author

initram commented Mar 24, 2017

Your version solves my issue. I used the VSIX. Thank you! When can I expect this as part of a normal release?

@OsirisTerje
Copy link
Member

I am a bit uncertain. I'm waiting for @CharliePoole's answer to my last comment in #143. It will probably be in 2.2, but it could also be out on a beta-feed. The version number will be above the one you have now, so it will be upgrade-able. The same applies for the nuget package.

@CharliePoole
Copy link
Member

@OsirisTerje I checked #143 but didn't see any questions for me to answer.

@initram
Copy link
Author

initram commented Jan 23, 2018

When will you release 2.2? I just had to help a fellow developer getting the custom build from the zip you provided to be able to run our unit tests. It has been almost a year... I do not understand what is holding back a release.

@OsirisTerje
Copy link
Member

Sorry for being unclear. We try to not release updates to the 2.X series, instead see what prevents people from moving to NUnit3. Are there any particular things that prevents this?

In itself this fix do deserve a new release, but it would be interesting to hear what is your upgrade blocker.

@OsirisTerje
Copy link
Member

OsirisTerje commented Jan 23, 2018

I'm closing the issue, as the PR is merged to master.

@OsirisTerje
Copy link
Member

@initram The pre-release package for the 2.2 adapter is now available on https://www.myget.org/feed/nunit/package/nuget/NUnitTestAdapter If you could check it out, it would be awesome.

@initram
Copy link
Author

initram commented Jun 6, 2019

Wow, a blast from the past...

We have since migrated to NUnit 3 and no longer have this issue. But good luck with your release.

@OsirisTerje
Copy link
Member

@initram Good to hear that you have migrated! That is what we want to hear :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants