0

I have my tests gathered in .NetStandard project (assembly) (as I need to test them through very different platforms). We can't run those directly as it requires the project to target something like .NetFramework or .Net Core.

So, I've created .Net Core project and referenced my .NetStandard project.

However, when running dotnet test ...csproj I obviously receive

No test is available in .... Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

... as there is obviously no magic and testing adapter can't read my mind and go to any referenced assembly automatically.

However, there must be some way of mentioning that to it, right? The documentation is quite modest about that, so I don't even know if this approach in general possible. However, when testing Xamarin.iOS/Android with TestRunners, they always have the option to add my assembly to test, like this: runner.Add(typeof(MyTestClass).Assembly).

UPDATE: Just to be clear, that this question point is not actually about targeting different platforms issue, but finding the way of running tests from .Net Core project (the way it already works for Xamarin):

  1. The tests should be placed in separate project/assembly as for Xamarin test projects they don't actually run in common way tests run (they run via a test runner inside of actually an iOS/Android app).
  2. This way it's handy to have the tests in .NETStandard assembly, which can be attached anywhere else.
  3. Again, this already works for Xamarin (platform-specific project attaching my .NETStandard library with tests) via a test runner (NUnit one), but it doesn't for .NET Core project.
  4. I don't need to run the tests on the .NET Standard assembly itself, I need they to be referenced from testable .NET Core project.

Is there any way I can be lucky with that?

Agat
  • 4,577
  • 2
  • 34
  • 62
  • 1
    [This answer](https://stackoverflow.com/a/44478400/1320845) relates to xunit, but it applies here. You should have one assembly that targets multiple frameworks (e.g. net472;netcoreapp2.2). – Charles Mager Feb 18 '19 at 22:24
  • Actually, my question has nothing to do with the "Already answered" one. There are at least two points which completely different in my question above. – Agat Feb 19 '19 at 07:52

0 Answers0