Skip to main content

C#

The following sections provide information on using Testspace with popular C# test frameworks and tools.

To push collected files simply use the Testspace client:

$ testspace static-analysis-results test-results code-coverage-results

Test Frameworks#

Microsoft Unit Test Framework#

Microsoft unit test framework is installed with Visual Studio and provides a framework for testing .NET code.

Testspace accepts TRX formatted Microsoft Unit Test assembly results. Here is an example of how to produce such:

vstest.console %TEST_DIR%\test-assembly.dll /Logger:trx

In the Testspace client command-line reference TestResults\*.trx as "test-results" files.

NUnit#

NUnit is a unit-testing framework for all .NET languages.

C# NUnit sample: https://github.com/testspace-samples/csharp.nunit

Note: The description that follows assumes that you are using Visual Studio to compile/link your source code.

Testspace accepts NUnit XML formatted NUnit Test assembly results. Here is an example of how to produce such:

nunit3-console %TEST_DIR%\test-assembly.dll --result:test-result.xml

In the Testspace client command-line reference test-result.xml as "test-results" file.

xUnit.net#

xUnit.net is a free, open source, community-focused unit testing tool for the .NET Framework.

Note: The description that follows assumes that you are using Visual Studio to compile/link your source code.

Testspace accepts xUnit.net XML formatted xUnit.net Test assembly results. Here is an example of how to produce such:

xunit.console %TEST_DIR%\test-assembly.dll -xml test-result.xml

In the Testspace client command-line reference test-result.xml as "test-results" file.

Code Coverage#

dotCover#

dotCover is a .NET unit test runner and code coverage tool.

Testspace accepts dotCover XML formatted results. Here is an example of how to produce such:

dotCover analyse /TargetExecutable=<path to target> /Output="coverage.xml"

In the Testspace client command-line reference coverage.xml as "code-coverage-results" file.

OpenCover#

OpenCover is a code coverage tool for .NET.

Testspace accepts OpenCover XML formatted results. Here is an example of how to produce such:

OpenCover.Console -target:<path to target> -output:"coverage.xml"

In the Testspace client command-line reference coverage.xml as "code-coverage-results" file.

Visual Studio Coverage#

Visual Studio Coverage is provided as part of the Microsoft unit test framework.

Testspace accepts BINARY or XML formatted Visual Studio Coverage results. Here is an example of how to produce such:

vstest.console %TEST_DIR%\test-assembly.dll /Logger:trx /EnableCodeCoverage

In the Testspace client command-line reference *.coverage as "code-coverage-results" files.

Static Analysis#

Compiler#

Any compiler relies on static analysis of the source code during compilation to generate its errors and warnings.

Testspace accepts Visual Studio style formatted build output logs. Simply write your build output to a file, e.g. build.log.

In the Testspace client command-line reference build.log{lint} as "static-analysis-results" file.

Visual Studio FxCop#

Visual Studio FxCop is the Microsoft's .NET Managed code analysis tool.

Testspace accepts Visual Studio FxCop XML formatted results. Here is an example of how to produce such:

msbuild <vcxprojectfile> /p:RunCodeAnalysis=True /p:CodeAnalysisLogFile=analysis.xml

In the Testspace client command-line reference analysis.xml as "static-analysis-results" file.

Alternatively, the actual build log could be used - besides compiler errors/warnings it also contains the static analysis output. Simply write your build output to a file:

msbuild <vcxprojectfile> /p:Configuration=config-name /p:Platform=platform-name /p:RunCodeAnalysisOnce=True /flp:LogFile=build.log;Encoding=utf-8

In the Testspace client command-line reference build.log{lint} as "static-analysis-results" file.