Search code examples
c#.netxamarinportability.net-standard-1.5

Xamarin portable .NETStandard 1.5 unit test


I created a portable class library Project selection for portable and then targeted it at .NETStandard 1.5 from the project propertiesenter image description here. I then created a second project with the exact same project settings, but added code to use for invoking and testing the code in the first project. But I have been unable to add MSTest to use for triggering execution. I tried using the guidance at stack overflow # 41350323 but ran into problems. Wondering if anyone out there has been able to use MSTest for unit testing portable .NETStandard class libraries. Note that I also tried using the guidance for .NET core but the MSTest framework nuget does not seem to support .NETStandard.

If not a unit test, then is there a way to invoke from a console? I just need to test my code and this should not be so difficult.


Solution

  • You can define logic in a .NET Standard project (don't use PCL though, use the .NET Standard Class Library template in VS2017 RC), but then the unit test project should have its target platform (UWP/Desktop/Xamarin or others) instead of .NET Standard. For example, in VS2017 RC, a typical unit testing project can be a .NET Core console app.