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

.NET Framework 4.6.2 test project using new .NET Standard 2.0 csproj format problem #383

Closed
vullnetyy opened this issue Sep 6, 2017 · 10 comments

Comments

@vullnetyy
Copy link

vullnetyy commented Sep 6, 2017

I have a .NET Framework 4.6.2 test project where myproject.csproj file is in the new csproj format. Resharper successfully discovers and runs all the tests. The NUnit3TestAdapter however, does not. Here are the errors I see in the Tests output of VS2017:

[2017-09-06 10:27:27 Warning] Exception System.InvalidOperationException, Exception converting X2TransferGUI.Tests.ReducerStateTest.ReducersCannotContainState
[2017-09-06 10:27:27 Warning] Operation is not valid due to the current state of the object.
[2017-09-06 10:27:27 Warning] Exception System.InvalidOperationException, Exception converting X2TransferGUI.Tests.SubsetsTest.SubsetsUsedByViewModelsMatchStoreProps
[2017-09-06 10:27:27 Warning] Operation is not valid due to the current state of the object.

NUnit 3.8.1 and NUnit3TestAdapter 3.8.0 installed as a Visual Studio 2017 Extension
Visual Studio Enterprise 2017 version 15.3.3
.NET Framework 4.6.2

@OsirisTerje
Copy link
Member

Can you upload a repro project?

@OsirisTerje OsirisTerje added the confirm We need a separate confirmation of this issue label Sep 6, 2017
@vullnetyy
Copy link
Author

Here you go sir: NUnitBugDemonstration.zip

NUnit 3.8.1.
NUnit3TestAdapter 3.8.0 is the one I have on my Visual Studio Enterprise 2017 version 15.3.3.

The original post mistakenly said 3.8.1 for the test adapter.

@vullnetyy
Copy link
Author

My apologies. I just discovered your release notes and tried adding

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />

and this makes my package references look like this:

<ItemGroup>
  <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
  <PackageReference Include="NUnit" Version="3.8.1" />
  <PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>

Using this successfully discovered and ran all my tests.

I propose that the exception messages shown in this case should point to the solution (your release notes.)

@ChrisMaddock
Copy link
Member

Could we make the Microsoft.NET.Test.Sdk package a NuGet dependency of the TestAdapter package?

@vullnetyy
Copy link
Author

vullnetyy commented Sep 8, 2017

That could be an elegant way to deal with this but the author may have objections to hard-coding "loosely required" dependencies like that.

@rprouse rprouse added is:bug pri:normal and removed confirm We need a separate confirmation of this issue labels Sep 16, 2017
@rprouse
Copy link
Member

rprouse commented Sep 16, 2017

Could we make the Microsoft.NET.Test.Sdk package a NuGet dependency of the TestAdapter package?

I have been considering doing so myself. It is a hard requirement for any tests using the new CSPROJ format. See nunit/nunit-console#291

@OsirisTerje
Copy link
Member

OsirisTerje commented Oct 9, 2017

@rprouse @ChrisMaddock
We have only one nuspec, and that one is afaik not target specific.
We could however add a targets file to achieve it.

@ChrisMaddock
Copy link
Member

Unfortunately, I don't think there's a way to detect 'uses new csproj'. I could be wrong however!

@OsirisTerje
Copy link
Member

Also considering older VS versions, perhaps it is not a good idea to attempt adding that dependency. It could be wiser to add it to the NUnitTemplate project instead.
Or, add our own AssemblyResolve event handler, as indicated in comments in nunit/nunit-console#291

@OsirisTerje
Copy link
Member

OsirisTerje commented Feb 2, 2018

I'm closing this, as there doesn't seem to be anything we can do to help the users here, except ensuring the templates and documentation are up to date.

For any new readers having this trouble, see comment above by @vullnetyy Sept 7th. on the missing .Net Test sdk.
Also see the blogpost I put up for tackling issues like this: http://hermit.no/how-to-resolve-cases-of-visual-studio-no-tests-appearing/

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

4 participants