这个问题的后续,我目前正在为我的项目(here)设置AppVeyor,我的.NET核心测试只显示在控制台输出中,而不显示在测试窗口中。
这是AppVeyor项目的链接:ci.appveyor.com/project/Sergio0694/neuralnetwork-net
如果某些测试失败,控制台会正确地显示一个错误,并将构建标记为失败,但tests窗口无论如何都是空的。来自shields.io的徽章也是如此,它显示了总共0个测试,即使我可以从控制台输出中看到许多测试正在执行。
以下是控制台输出:

这是测试窗口:

为了在控制台窗口之外正确地报告它们,我还需要进行其他设置吗?
发布于 2018-01-13 07:39:30
发布于 2018-11-15 05:32:15
向您的测试项目添加其他未使用的引用的一种更简洁的替代方案是在您的测试脚本中执行此操作:
cd <test_project_dir>
nuget install Appveyor.TestLogger -Version 2.0.0
cd ..
dotnet test --no-build --no-restore --test-adapter-path:. --logger:Appveyor <test_project_dir>这与添加引用具有相同的效果,因为它使testlogger二进制文件对测试框架可用,但它实际上不会更改测试项目,因此不需要使用Appveyor的人在克隆和构建您的repo时安装包。
与输出并随后上传.trx文件(如上面的PS脚本)相比,此解决方案的略微优势在于,您应该实时获得测试结果,而不是在最后获得所有结果。
示例appveyor.yml:
version: 0.0.{build}
build_script:
- cmd: dotnet build MySolution.sln
test_script:
- cmd: cd Test
- cmd: nuget install Appveyor.TestLogger -Version 2.0.0
- cmd: cd ..
- cmd: dotnet test --no-build --no-restore --test-adapter-path:. --logger:Appveyor Test发布于 2018-02-28 06:44:25
您可以将AppVeyor.TestLogger包添加到项目中,但可以在不更改代码的情况下完成此操作。您需要将测试结果输出为AppVeyor能够理解的xml文件格式,然后将其上传到他们的HTTP API。下面的powershell代码片段将遍历您的解决方案并找到每个测试项目,在csproj上调用dotnet test并将输出记录到test-result.trx,然后将文件上传到AppVeyor。
$config = "release"
# Find each test project and run tests and upload results to AppVeyor
Get-ChildItem .\**\*.csproj -Recurse |
Where-Object { $_.Name -match ".*Test(s)?.csproj$"} |
ForEach-Object {
# Run dotnet test on the project and output the results in mstest format (also works for other frameworks like nunit)
& dotnet test $_.FullName --configuration $config --no-build --no-restore --logger "trx;LogFileName=..\..\test-result.trx"
# if on build server upload results to AppVeyor
if ("${ENV:APPVEYOR_JOB_ID}" -ne "") {
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test-result.trx))
}
# don't leave the test results lying around
Remove-Item .\test-result.trx -ErrorAction SilentlyContinue
}https://stackoverflow.com/questions/48235374
复制相似问题