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

Running tests in a csproj with multiple TargetFrameworks #624

Closed
JamesNK opened this issue Mar 17, 2017 · 13 comments
Closed

Running tests in a csproj with multiple TargetFrameworks #624

JamesNK opened this issue Mar 17, 2017 · 13 comments
Labels

Comments

@JamesNK
Copy link
Member

JamesNK commented Mar 17, 2017

Inside VS2017 I want to be able to discover and run tests from a csproj that has multiple TargetFrameworks. I believe that right now vstest only takes tests from the first framework in the list and ignores the rest.

I want the UI to discover tests for all frameworks and then let me choose whether to run tests from all frameworks (e.g. net45 and netcoreapp1.0), or to choose one framework (e.g. net45) and run tests only from it.

This feature is critical for anyone who writes a library that targets multiple platforms and wants to migrate to the new csproj system. Without it then the test integration in VS2017 isn't useful.

@magol
Copy link

magol commented Mar 17, 2017

This is a very enoying bug.

@airbreather
Copy link

airbreather commented Aug 19, 2017

Along with this, I'd also like some support for having the TargetFramework used by the tests to be detached from the TargetFramework for the project being tested.

I know I can have the ProjectReference say Properties="TargetFramework=net35" or whatever, but ideally I should be able to tell the framework to build and test all the combinations of:

Framework for Project Under Test Framework Used to Run Tests
net20 net461
net35 net461
net461 net461
netstandard1.0 net461
netstandard1.0 netcoreapp1.0
netstandard1.0 netcoreapp1.1
netstandard2.0 net461
netstandard2.0 netcoreapp2.0

So if my multi-targeted library has some slight platform implementation differences in all of net20, net35, net46, netstandard1.0, and netstandard2.0 I'd like to have just one test project that includes the shiny APIs from net461, while also making sure that the project being tested actually works on the .NET Core 1.0, 1.1, and 2.0 implementations of .NET Standard.

From my perspective, this feels like the kind of use case that shouldn't require me to make a bunch of different .csproj files... ideally, it seems, I'd just have one Test .csproj file that specifies the above 8 (<TargetFrameworks>net461;netcoreapp1.0;netcoreapp1.1;netcoreapp2.0</TargetFrameworks> might be added to the top so that the normal build system makes sure to build all the different variants properly) and then just runs with it.

I'm perfectly content with manually writing .csproj files for this kind of thing.

If you consider this to be a distinct issue that's separate enough from the other stuff discussed above, let me know and I'll copy it into a new issue.

(edit: "I should be able to tell vstest" --> "I should be able to tell the framework", since as I understand it, vstest isn't at all responsible for building the projects themselves)

@Faizan2304
Copy link
Contributor

@airbreather

Along with this, I'd also like some support for having the TargetFramework used by the tests to be detached from the TargetFramework for the project being tested.

Please create a separate issue for this.

@airbreather
Copy link

@Faizan2304 done, #1013

@Faizan2304
Copy link
Contributor

Thank you @airbreather.

@pvlakshm pvlakshm added exp: ide and removed backlog labels Nov 15, 2017
@snkota
Copy link

snkota commented Nov 15, 2017

Created this issue in developers community, Hence closing the issue. Below is the link
https://developercommunity.visualstudio.com/content/problem/150864/running-tests-in-a-csproj-with-multiple-targetfram.html

@jnm2
Copy link

jnm2 commented Feb 14, 2018

I'm leaving a link to that issue in the NUnit test adapter repository readme. When do you think we might see this feature?

@johnwc
Copy link

johnwc commented May 15, 2018

All, follow that link and use the vote functionality on the site for the issue so they know it has significance.

@johnwc
Copy link

johnwc commented Aug 17, 2018

It's been a year, any update to this?

@OsirisTerje
Copy link

Is anything happening with this?

The assumption it works with the first framework stated, might not be entirely true either. I do experience that it sometimes picks the 2nd one. This issue really need to be fixed.
For a good repro, go to Visual Studio adapter for NUnit3 https://github.com/nunit/nunit3-vs-adapter

@airbreather
Copy link

airbreather commented May 22, 2019

VS2019 16.2 Preview 1 adds something that sounds a lot like this.

Testing it out on something basic, it seems to work for me.

Edit: not sure what's up with this... I definitely didn't do it on purpose, whatever it was:
image

@MeikTranel
Copy link

Right now dotnet test and visual studio both support this scenario. dotnet test however lacks the conciseness of the test explorer ui we now have in Visual Studio 2019. Should work on the console logging for multitarget testing be moved to another issue? If so i'd consider this issue to be done.

Any thoughts?

@kendrahavens
Copy link

As of Visual Studio 2019 Version 16.2 the test explorer can display and run multi-targeted tests. For more info on using the target framework groupby or column to search or filter tests see our docs.

This issue can be closed.

@JamesNK JamesNK closed this as completed Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests