-
Notifications
You must be signed in to change notification settings - Fork 19
Modes of Operation
AltCover can be used in a variety of ways, from being almost like the original NCover
or current OpenCover
, where everything is done all in one, to a complete separation of the stages of instrumentation, testing and then reporting.
This is a non-exhaustive list of combinations
- Instrument and test now, classic mode -- most "this is how I use OpenCover" for the full .net framework
- Instrument now, test later, classic mode
- Instrument and test now, runner mode
- Instrument in place and test now, runner mode
- Instrument now, test later, runner mode
- Instrument now, test later, collect coverage after that -- most .net core friendly
- Instrument now, then gather coverage from a running application -- for web applications, services and the like
In the following, when I say altcover
, that will mean either <path to>/AltCover.exe
or dotnet <path to>/AltCover.dll
unless explicitly specified otherwise.
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
, with the test command line being specified after a--
to execute the tests on the assemblies in the new location, and rely on theProcessExit
handler to write from memory into the XML file.
This is closest in style to running with OpenCover or the old NCover, and is sufficient for moderately large coverage sets in the full .net framework, where the handler has a couple of seconds to work.
Disadvantages
- doesn't work well for
dotnet
because the exit handler has much less time to operate - doesn't work at all for
dotnet test
because the instrumented assemblies are somewhere else - only a subset of OpenCover format (sufficient for use with coveralls.io and ReportGenerator) is produced
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
- Execute the tests on the assemblies in the new location, and rely on the
ProcessExit
handler to write from memory into the XML file.
This is sufficient for moderately large coverage sets in the full .net framework, where the handler has a couple of seconds to work
Disadvantages
- doesn't work well for
dotnet
because the exit handler has much less time to operate - sort-of works for
dotnet test
because the instrumented assemblies can be copied back into place for testing as a separate manual step - only a subset of OpenCover format (sufficient for use with coveralls.io and ReportGenerator) is produced
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
, plus any of[--single]
[--linecover|branchcover]
; then specifyaltcover runner
after a--
with the test command line being specified after yet another--
to execute the tests on the assemblies in the new location.
This is close in style to running with OpenCover or the old NCover, and will produce all the supported OpenCover format output
Disadvantages
- doesn't work at all for
dotnet test
because the instrumented assemblies are somewhere else - cumbersome command line
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
, plus any of[--single]
[--linecover|branchcover]
, also specifying--inplace
; then specifyaltcover runner
after a--
with the test command line being specified after yet another--
to execute the tests on the assemblies in the built location.
This is close in style to running with OpenCover or the old NCover, and will produce all the supported OpenCover format output
Disadvantages
- your build artifacts are saved off, so many not be where your build pipeline wants them
- cumbersome command line
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
, plus any of[--single]
[--linecover|branchcover]
- Run
altcover runner
to generate the XML report with the test command arguments being specified after a--
to execute the tests on the assemblies in the built location.
With --inplace
as part of step 1, this will work with dotnet test
Disadvantages
- With
--inplace
your build artifacts are saved off, so many not be where your build pipeline wants them
- Run
altcover
to instrument your binaries, using any of the options up to and including--opencover
, plus any of[--single]
[--linecover|branchcover]
, also specifying--save
- Execute the tests on the assemblies in the new location.
- Run
altcover runner --collect -r <path to instrumented folder>
to generate the XML report
This is the style of operation of coverlet; and with --inplace
as part of step 1, this will work with dotnet test
in exactly the same way.
Disadvantages
- multiple steps
- With
--inplace
your build artifacts are saved off, so many not be where your build pipeline wants them