Reputation: 24212
When you have a .NET Standard library, the test project needs to target an actual platform. The most logical choice (I assume) is to target .NET Core because it runs on multiple operating systems, but it's also possible to target multiple platforms as demonstrated in the xUnit.net documentation:
With a single test project, we can have our tests run against multiple target frameworks. Open the .csproj file and change this:
<PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework> </PropertyGroup>
To this:
<PropertyGroup> <TargetFramework>net452;netcoreapp2.1</TargetFramework> </PropertyGroup>
Is there any practical reason for doing so, i.e. are there situations that require you to target multiple platforms?
The only reason I can think of is to be aware of bugs in a specific platform, which has occurred a couple times in .NET Framework. But that feels like you would be testing the platform instead of your library, so I'm not sure if that's a good enough reason.
Upvotes: 2
Views: 1430
Reputation: 3370
I think the only reason where this makes sense is if you are worried about the platform APIs behaving differently between .NET Framework and .NET Core.
For the most part, the APIs behave the same across platforms, but there might be cases where there are slight differences. Some of those differences are documented here.
Upvotes: 2
Reputation: 868
If you create a NETStandard
library, you should consider running the tests on every target platform
and runtime version
that you expect to see usage on.
If you plan to publish your library, you can't be sure about who is going to reference it in which scenario.
Not only are there differences between target platforms, there are also changing implementation details from one version to another of the same platform (see this example).
This isn't so much testing the platform rather it's testing if your library plays nicely with the platform.
Upvotes: 0