gpt4 book ai didi

nunit - 如何使NUnit3TestAdapter与.Net Standard 2.0一起使用?

转载 作者:行者123 更新时间:2023-12-03 10:41:49 28 4
gpt4 key购买 nike

如何使NUnit3TestAdapter与.Net Standard 2.0一起使用?

我收到以下错误:

1>C:\Nikeza\Mobile\Nikeza.Mobile\Tests\ExampleBased.fsproj :

warning NU1701: Package 'NUnit3TestAdapter 3.9.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'.

This package may not be fully compatible with your project. 1>ExampleBased -> C:\Nikeza\Mobile\Nikeza.Mobile\Tests\bin\Debug\netstandard2.0\ExampleBased.dll

最佳答案

您没有提供足够的信息来诊断项目文件有什么问题,但是NUnit Adapter 3.9.0确实可以与.NET Standard 2.0和F#一起使用。我认为您的测试项目针对的是.NET Standard。它需要针对.NET Core或.NET 4.6.1+。测试项目被视为可执行文件,它们需要针对特定​​的框架而不是.NET Standard。但是,您要测试的代码可以是.NET Standard。

您应该遵循Unit testing F# libraries in .NET Core using dotnet test and NUnit文档并阅读NUnit文档.NET Core and .NET Standard

您的项目文件应如下所示:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="Tests.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MathService\MathService.fsproj" />
</ItemGroup>

</Project>

关于nunit - 如何使NUnit3TestAdapter与.Net Standard 2.0一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48043023/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com