Ant*_*ean 5 nunit docker .net-core
我有这个 .NET Core 1.1 解决方案,包括一个 ASP.NET Core 项目和一个 NUnit 测试项目。每个项目都有必要的属性(如有必要,我可以显示更多)。
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
我可以在本地 (Windows 10) 恢复、构建和运行测试套件,没有任何问题。
$ dotnet restore
Restoring packages for...
Restore completed in...
Generating MSBuild file...
$ dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Example -> ...
Test -> ...
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed ...
$ cd test/
$ dotnet test
Build started, please wait...
Build completed.
Test run for ...
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
Total tests: 11. Passed: 11. Failed: 0. Skipped: 0.
Test Run Succeeded.
Test execution time: ...
Run Code Online (Sandbox Code Playgroud)
测试套件使用 NUnit 3,我使用的是所有最新的稳定版本。这是有趣的包参考。
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
<PackageReference Include="FluentAssertions" Version="4.19.3" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.3" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
Run Code Online (Sandbox Code Playgroud)
但是,当我从 .NET Core SDK Docker 映像/容器运行测试时,它们会严重失败!
活动的测试运行已中止。原因:无法与测试主机进程通信。
这是简单的 Dockerfile
FROM microsoft/dotnet:1.1-sdk
WORKDIR /app
COPY . .
Run Code Online (Sandbox Code Playgroud)
恢复和构建工作找到了,但测试中止!
$ docker image build --tag example:latest .
...
$ docker container run --rm -it example:latest
root@abcdef12345:/app# dotnet restore
...
root@abcdef12345:/app# dotnet build
...
root@abcdef12345:/app# cd test/
root@abcdef12345:/app# dotnet test
...
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
The active test run was aborted. Reason: Unable to communicate with test host process.
Run Code Online (Sandbox Code Playgroud)
搜索此错误消息让我无处可去。我不确定如何调试测试运行中止。更高级别的冗长不会打印任何有用的东西。让我知道我可以尝试获取更多信息、消除可能性并提供更多有用信息!
| 归档时间: |
|
| 查看次数: |
663 次 |
| 最近记录: |