Running tests
Capture test execution and coverage from MSTest, NUnit, and xUnit with the SeaLights .NET Agent.
Running tests with MSTest, NUnit, or xUnit
You have two ways to capture tests from a supported framework:
Wrap the test command with the SeaLights agent.
Use the Profiler-Initiated Collector, or PIC, when you cannot change the startup command.
Minimum System Requirements
MSTest Framework 1.4.0 (a.k.a. MSTest v2) and higher
NUnit 3.10.0 and higher
XUnit 2.3.0 and higher
VSTest.Console.exe 17.2 and higher
Wrapper to the test command
When you use MSTest, NUnit, or xUnit, wrap the test runner command with the agent. The test listener tracks execution and uploads results automatically.
Here is a sample command with a Lab ID setup.
.\sl-dotnet-agent\SL.DotNet.exe run --tags "mytag" --instrumentationMode tests --labId "<lab-id>" --testStage "Functional Tests" --target "C:\tools\testrunner.exe" --workingDir (Get-Location) --targetArgs "MyTest.dll --flag1 true --flag2 false"./sl-dotnet-agent/SL.DotNet run --tags "mytag" --instrumentationMode tests --labId "<lab-id>" --testStage "Functional Tests" --target "/usr/local/bin/testrunner" --workingDir "$(pwd)" --targetArgs "MyTest.dll --flag1 true --flag2 false"CI examples
These examples wrap dotnet test directly in the pipeline.
PIC integration
Set the environment variables required for profiling and PIC in the same shell session that runs the tests. In the examples below, SL_AGENT_ROOT is an absolute path to the unpacked agent directory.
Environment variables should be set in the same session where test runner will be executed.
Avoid setting PIC or profiling variables system-wide or user-wide. That can attach the profiler to unrelated .NET processes.
You can now execute the tests in the same session with the regular test command.
Last updated
Was this helpful?

