项目初始化
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
**/bin/
|
||||
**/obj/
|
||||
**/TestResults/
|
||||
**/.vs/
|
||||
**/.vscode/
|
||||
.git/
|
||||
.gitignore
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
*.user
|
||||
*.suo
|
||||
@@ -0,0 +1,7 @@
|
||||
bin/
|
||||
obj/
|
||||
TestResults/
|
||||
.vs/
|
||||
.vscode/
|
||||
*.user
|
||||
*.suo
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# 测试项目用 SDK 镜像即可(dotnet test 需要 SDK,而不是 runtime)
|
||||
# 注意:这里不写 `# syntax=docker/dockerfile:1`,避免额外拉取 dockerfile 前端镜像
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS test
|
||||
WORKDIR /src
|
||||
|
||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 \
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
|
||||
DOTNET_NOLOGO=1
|
||||
|
||||
# 1) 先只复制 csproj 做 restore,充分利用 Docker 层缓存
|
||||
COPY TySpace.Ttc.RegressionSuite.csproj ./
|
||||
RUN dotnet restore TySpace.Ttc.RegressionSuite.csproj
|
||||
|
||||
# 2) 再复制源码并预编译,让编译错误在 build 阶段就暴露
|
||||
COPY . .
|
||||
RUN dotnet build TySpace.Ttc.RegressionSuite.csproj -c Release --no-restore
|
||||
|
||||
# 3) 容器启动即跑测试;结果写到 /src/TestResults,可挂载出来
|
||||
ENTRYPOINT ["dotnet", "test", "TySpace.Ttc.RegressionSuite.csproj", \
|
||||
"-c", "Release", "--no-build", "--no-restore", \
|
||||
"--logger", "trx;LogFileName=test-results.trx", \
|
||||
"--results-directory", "/src/TestResults"]
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace TySpace.Ttc.RegressionSuite;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
regression-suite:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: tyspace-ttc-regressionsuite-tests:latest
|
||||
# 把测试报告(trx)输出到宿主机,方便 CI 或本地查看
|
||||
volumes:
|
||||
- ./TestResults:/src/TestResults
|
||||
Reference in New Issue
Block a user