NUnit
Submit and collect your NUnit results in Testiny to track automated test runs. By integrating NUnit with Testiny, you can gain valuable insights into your testing process. Track automation results over time, identify frequently failing tests, and detect patterns in test failures to fix CI failures and find flaky tests.
Running NUnit Tests & Generating
There are several ways to run your NUnit tests, for example using common IDEs, such as Visual Studio or Rider, or to use dotnet test. Depending on the framework there might be different settings needed to save result files, e.g. you might need to set TestOutputXml to an output folder and/or install the NUnitXml.TestLogger package and specify it as a reporter.
Testiny supports the NUnit 3.0 XML format, so you don't need to transform your report file to another format.
Import Results to Testiny
Make sure you've generated an API key and use the Testiny CLI to import the results to Testiny:
- Node.js/npm
- Linux
- Windows
- macOS
export TESTINY_API_KEY=****
npx @testiny/cli automation --project ID_OR_KEY --source "frontend" --nunit output/*.xml export TESTINY_API_KEY=****
./testiny-importer-linux automation --project ID_OR_KEY --source "frontend" --nunit output/*.xml set TESTINY_API_KEY=****
testiny-importer-win.exe automation --project ID_OR_KEY --source "frontend" --nunit output/*.xml export TESTINY_API_KEY=****
./testiny-importer-macos automation --project ID_OR_KEY --source "frontend" --nunit output/*.xml In the above example, the environment variable TESTINY_API_KEY is set to authenticate the request.
The --project flag specifies the target Testiny project using its ID or key and the --source flag categorizes the test results (e.g., frontend, backend, integration tests, ...).
The --nunit flag specifies the format of the specified test result file(s).
Once executed, the Testiny CLI will automatically create a new automated test run in Testiny and import all results from the specified report(s).
Custom Properties
Use NUnits's PropertyAttribute fixture to log additional information for a test.
Test Keys
testid or testkey are optional properties that can be used to uniquely identify a test across automation runs:
public class MyTests
{
[Test, Property("testkey", "my-test-id-1")]
public void ExampleTest()
{ /* ... */ }
}
If not specified, a combination of title and folder path will be used to identify a test.
Custom Result Fields
Custom fields are supported via custom properties and can be included as fields via the CLI:
public class MathTests
{
[Test, Property("type", "regression")]
public void AdditionTest()
{ /* ... */ }
}
Import these properties with the option --custom-result-fields:
npx @testiny/cli automation --project ID_OR_KEY --source "frontend" --custom-result-fields=regression --nunit output/*.xml
More resources
Here are some further resources to help you get started with integrating NUnit with Testiny, including CI/CD integration examples, a full automation guide, and the Testiny CLI.