用于CI/CD管道中未找到的单元测试的文件
我的单元测试项目中的参考文件并设置为始终复制。这过去了。
[Test]
public void MyTest()
{
// Arrange
var json = File.ReadAllText("testfiles\\mytest.json");
// Act & Assert
Assert.IsNotNull(json);
}
在GitHub的CI/CD管道中,找不到mytest.json
。
如何获得部署的mytest.json
文件,或者如果部署了文件,如何将测试罚款?
yaml文件 - github为您生成的默认.NET
name: .NET
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
My unit tests reference files that are in the project and set to copy always. This passes.
[Test]
public void MyTest()
{
// Arrange
var json = File.ReadAllText("testfiles\\mytest.json");
// Act & Assert
Assert.IsNotNull(json);
}
In the CI/CD pipeline for GitHub, mytest.json
is not found.
How do I get the mytest.json
file deployed, or if it is deployed how do I get the test to fine it?
The YAML file - the default .NET one that gitHub generates for you
name: .NET
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两件事
更改
运行:ubuntu-latest
toruns-on:windows-latest
允许将文件输出到正确的目录更改
run:dotnet test -no-Build - Verbosity normal
to运行:dotnet test-verbosity normal
也有帮助。Two things
Changing
runs-on: ubuntu-latest
toruns-on: windows-latest
allowed the files to be output to the correct directoryChanging
run: dotnet test --no-build --verbosity normal
torun: dotnet test --verbosity normal
helped as well.