如何为 .NET 项目中的单元测试创建 GitHub 操作?
How to create GitHub Actions for unit testing in .NET projects?
我使用 NUnit 框架来测试我的 .NET 项目。我想通过 GitHub 操作 运行 我的测试。
我的项目的汇编中应该包含什么?也许有一些标准的例子?
您无需将任何内容包含到您的程序集中即可使用 GitHub 操作 运行 您的测试。只需在 .github/workflows
文件夹中创建包含以下内容的工作流文件(假设您有 .NET Core 项目):
---
name: Tests
on: push
jobs:
tests:
name: Unit Testing
runs-on: windows-latest
steps:
- uses: actions/checkout@v2.1.0
- run: dotnet test
dotnet
is pre-installed on windows
machine but is not pre-installed on macos
and ubuntu
. So, you have to install dotnet
by adding an extra step in case you want to run it on one of these machines. You can use actions/setup-dotnet action for this purpose.
我使用 NUnit 框架来测试我的 .NET 项目。我想通过 GitHub 操作 运行 我的测试。
我的项目的汇编中应该包含什么?也许有一些标准的例子?
您无需将任何内容包含到您的程序集中即可使用 GitHub 操作 运行 您的测试。只需在 .github/workflows
文件夹中创建包含以下内容的工作流文件(假设您有 .NET Core 项目):
---
name: Tests
on: push
jobs:
tests:
name: Unit Testing
runs-on: windows-latest
steps:
- uses: actions/checkout@v2.1.0
- run: dotnet test
dotnet
is pre-installed onwindows
machine but is not pre-installed onmacos
andubuntu
. So, you have to installdotnet
by adding an extra step in case you want to run it on one of these machines. You can use actions/setup-dotnet action for this purpose.