User Tools



C++

The following sections provide information how to produce Testspace accepted result output in popular C++ test frameworks and tools.

To push the collected result files to Testspace simply use the following client command line:

testspace static-analysis-results test-results code-coverage-results credentials@org-name.testspace.com/project-name/space-name 

where:

For more information on pushing results refer to the Collecting Data article.


Test Frameworks

Google Test

Google Test is a unit testing framework for C++.

Testspace accepts the JUnit XML formatted Google Test application results. Here is an example of how to produce such:

$TEST_DIR/sample1_unittest --gtest_output=xml:sample1.xml
$TEST_DIR/sample2_unittest --gtest_output=xml:sample2.xml
$TEST_DIR/sample3_unittest --gtest_output=xml:sample3.xml
$TEST_DIR/sample4_unittest --gtest_output=xml:sample4.xml

In the Testspace client command line reference sample*.xml as "test-results" files.

CppUTest

CppUTest is a unit testing and mocking framework for C/C++.

Testspace accepts the JUnit XML formatted CppUTest application results. Here is an example of how to produce such:

$TEST_DIR/application-name -o junit

In the Testspace client command line reference cpputest_*.xml as "test-results" files.

Catch

Catch is a multi-paradigm automated test framework for C++.

Testspace accepts the JUnit XML formatted Catch application results. Here is an example of how to produce such:

$TEST_DIR/application-name -r junit -o results.xml

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

Microsoft Unit Test Framework

Microsoft unit test framework is installed with Visual Studio and provides a framework for testing unmanaged code written in C++.

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

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

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


Code Coverage Tools

BullseyeCoverage

BullseyeCoverage is a C++ code coverage analyzer used to improve the quality of software.

Testspace accepts Bullseye XML formatted results. Bullseye does not produce this natively, however it provides covxml, a command line utility, that converts a native bullseye data file to the desired XML Report. Here is an example of how to produce such:

covxml -f bullseye.cov -o coverage.xml

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

Gcov

Gcov is a tool you can use in conjunction with GCC to test code coverage in your programs.

Note: The description that follows assumes that you are using GCC to compile/link your source code instrumented for coverage analysis.

Testspace accepts Cobertura XML formatted results. Gcov does not produce this natively, however there are several widely adopted utilities that could be used to interpret the native gcov data files and generate the desired XML Report. Here is couple of examples of how to produce such:

  • using gcovr, a utility for managing the use of the GNU gcov
gcovr -x -o coverage.xml
lcov --rc lcov_branch_coverage=1 -c -o temp.info
python lcov_cobertura.py temp.info -o coverage.xml

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

OpenCppCoverage

OpenCppCoverage is an open source code coverage tool for C++ under Windows.

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

OpenCppCoverage --sources=\path\to\source --export_type=cobertura:coverage.xml -- test-app.exe

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 the 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 Tools

Compiler

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

Testspace accepts GCC/Emacs or 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.

Cppcheck

Cppcheck is a static analysis tool for C/C++ code.

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

cppcheck --xml-version=2 /path/to/source > analysis.xml

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

CPPLint

CPPLint is the Google's C++ style guide code checker.

Testspace accepts Visual Studio style formatted output logs. Simply write your analysis output to a file:

./cpplint.py /path/to/source 2>&1 > analysis.log

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

Klocwork

Klocwork is a static code analysis tool for C/C++, Java, and C#.

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

kwcheck list -F xml --report analysis.xml /path/to/source
kwcheck run -F xml --report analysis.xml /path/to/source

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

OCLint

OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code.

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

oclint -report-type pmd -o analysis.xml /path/to/source 

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

PC-lint

PC-lint is a static analysis tool for C/C++ source code.

Testspace accepts Visual Studio style formatted output logs. Here is an example of how to produce such:

Lint-nt +ffn -width(0) -hf1 -format="%f(%l): %t %n: %m" -os(analysis.log) /path/to/source

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

Vera++

Vera++ is a programmable tool for verification, analysis and transformation of C++ source code.

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

vera++ --checkstyle-report analysis.xml /path/to/source 

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

Visual Studio PREfast

Visual Studio PREfast is the Microsoft's native C/C++ code analysis tool.

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

msbuild <vcxprojectfile> /p:Configuration=config-name /p:Platform=platform-name /p:RunCodeAnalysisOnce=True 

In the Testspace client command line reference config-name\platform-name\vc.nativecodeanalysis.all.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.

1) Depending on the version of Visual Studio there are different test runners available.

Page Tools