Xamarin 可移植 .NETStandard 1.5 单元测试

Xamarin portable .NETStandard 1.5 unit test

我创建了一个可移植的 class 库 and then targeted it at .NETStandard 1.5 from the project properties. 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 但是 运行 遇到了问题。想知道是否有人能够使用 MSTest 对可移植 .NETStandard class 库进行单元测试。请注意,我也尝试使用 .NET core 的指南,但 MSTest 框架 nuget 似乎不支持 .NETStandard。

如果不是单元测试,那么有没有办法从控制台调用?我只需要测试我的代码,这应该不难。

您可以在 .NET Standard 项目中定义逻辑(尽管不要使用 PCL,在 VS2017 RC 中使用 .NET Standard Class 库模板),然后单元测试项目应该有它的目标平台(UWP/Desktop/Xamarin 或其他平台)而不是 .NET Standard。例如,在 VS2017 RC 中,一个典型的单元测试项目可以是一个 .NET Core 控制台应用程序。