Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan committed Nov 17, 2016
1 parent d75a385 commit cf992e6
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# VSOpenCPPCoverage
# Free C++ Code Coverage

VSOpenCPPCoverage is a Visual Studio extension that calculates code coverage for C++ applications and Visual Studio C++ native tests. Basically it provides
CPPCoverage is a Visual Studio extension that calculates code coverage for C++ applications and Visual Studio C++ native tests. Basically it provides
you easy-to-use, light-weight C++ code coverage, right from Visual Studio and with the features you expect from code coverage.

This extension works with both the 32-bit and 64-bit versions of OpenCPPCoverage.

# Installation

Prerequisites: VS2013 or VS2015. Any edition should work, even though this is only tested on VS2015 Community.

- Install OpenCPPCoverage x64 and/or x86 from https://opencppcoverage.codeplex.com/ .
- Install this extension: https://github.com/atlaste/VSOpenCPPCoverage/raw/master/CoverageExt/CoverageExt.vsix .

# Getting started

Working with VSOpenCPPCoverage is a breeze. Basically install and use, there's nothing more to it:
Working with CPPCoverage is a breeze. Basically install and use, there's nothing more to it:

- Either create a standard C++ / MS Test application, or run a simple C++ / console application. Note that OpenCppCoverage assumes that there is no user input during the test run.
- Build your solution in Debug mode.
Expand All @@ -40,45 +37,56 @@ Working with VSOpenCPPCoverage is a breeze. Basically install and use, there's n

![alt tag](Screenshots/Pragmas.png)

- IsDebuggerAttached is overwritten with 'return false'.
- The CodeCoverage output window will give you the current status of the process. Stdout is forwarded here as well.
- If you don't use MSTest, you can still use the Cobertura XML file generated by OpenCPPCoverage as "CodeCoverage.xml" to the solution folder.
- Small memory footprint and fast. Data is stored in a simple bit vector. Even if you have a million lines of code, VSOpenCPPCoverage will only use 250 KB of memory.
- Small memory footprint and very fast. Even if you have a million lines of code, CPPCoverage will only use kilobytes of memory for coverage.

# Support and maintenance

At NubiloSoft, we use this VSOpenCPPCoverage addin on a daily basis in a real environment on a huge C++ code base. We want this to be good. And since this is not our core
CPPCoverage is 100% open source and 100% for free.

At NubiloSoft, we use this CPPCoverage addin on a daily basis in a real environment on a huge C++ code base. We want this to be good. And since this is not our core
business, we are willing to make it available for free. Simple as that.

Over the period that we've used this extension, it has proven to be both reliable and stable, resulting in only a very few issues and very little work for us to maintain it.
However, if you do find a bug or think the tool lacks a feature, please let us know by posting it in 'issues'.

# Coming up
# If the tool doesn't work...

There are a few likely suspects to check:

- Check the Coverage output window in Visual Studio!
- Are PDB's available? Can you debug the application? If not, code coverage won't work.
- If your (Native unit test DLL) unit tests aren't running in Visual Studio, they're also not running in the coverage tool. Obviously this is the same when you're using an executable.
- Is all your source code in a child folder of your solution? If not, you can run Coverage-x86 or Coverage-x64 as executable and store the output in the solution folder.
Basically the recipe is as follows:

[install folder]\Resources\Coverage[-x86 / -x64].exe -o "[solution folder]\CodeCoverageTest.cov" -p "[root path of your code; omit the trailing '\']" -- "[executable to run...]" [... optional arguments...]

# Advanced users

Most people want to integrate code coverage in their test environment. Coverage-x86.exe and Coverage-x64.exe will provide just that. We support emitting Cobertura XML files,
which can be processed by a lot of tools.

Over the past year we have used OpenCPPCoverage with our coverage tool. And even though OpenCPPCoverage is pretty decent, we feel it just cannot deliver everything that we need.
Therefore we've been working on a better alternative:
If you want even more control, grab the code from the Coverage project, change the executable that's executed and you're done.

- OpenCPPCoverage seems to be pretty heavy. We wanted something that's fast as hell, since we're measuring all the time. During early tests, we've measured our toolkit to be
10x faster.
# Measuring code coverage

In the early versions of this tool, we've used OpenCPPCoverage as an external dependency. And even though OpenCPPCoverage is pretty decent, we feel it just cannot deliver
everything that we need. Therefore we've been working on a better alternative, which is available *now*:

- OpenCPPCoverage seems to be pretty heavy. We wanted something that's fast as hell, since we're measuring all the time.
- The relevant #pragma's are handled by the coverage tool, so that files are properly ignored by the coverage engine.
- We're working with production-grade software, so we want the memory footprint of out coverage tool to be very small.
- We want integration in our test suites. It makes little sense to run a separate memory leak checker, a separate coverage checker and a separate unit test runner. We want all
those things at once.
- Better handling of filters for "normal" solutions. We want to measure coverage on our solution, nothing more and nothing less.
- IsDebuggerAttached is giving us a hard time. We've implemented a workaround for this in the new coverage tool.

Because of this, we decided to implement our own full-fledged C++ code coverage toolkit.

Even though the new coverage tools support Cobertura XML files, it's not preferred. We've created a new text-based file, which is way smaller and more suitable for code coverage.

The projects Coverage-x86 and Coverage-x64 are the result of this, which already provide an extremely fast code coverage tool. For the most part it already works great; for
most applications you don't even notice that coverage is being measured. However, there are still some problems to be solved, most notably the ones with child processes.
This current limitation makes it impossible to run VS unit tests, so the current build is still aimed at using OpenCPPCoverage. In the next days (weeks?) this will be solved
though.

More importantly, the code base for 'Coverage' is small, making it possible to integrate code coverage in your custom-made test applications. For example, our test code
measures things like memory leaks on-the-fly.
- IsDebuggerAttached is giving us a hard time. We've implemented a nice workaround for this in the new coverage tool.
- We found that a lot of time was spent writing Cobertura files. Even though the new coverage tools support Cobertura XML files, it's not preferred. We've created a new
text-based file, which is way smaller and more suitable for code coverage.

If you want to toy with it, grab the solution, go to 'Settings.cs' and change UseNativeCoverageSupport to 'true'. Build, install visx.
The projects Coverage-x86 and Coverage-x64 are the result of this, which provide this new coverage tool. For the most part it already works great; for
most applications you don't even notice that coverage is being measured.

# License

Expand Down

0 comments on commit cf992e6

Please sign in to comment.