-
Notifications
You must be signed in to change notification settings - Fork 247
Usage
NOTE: When you install OpenCover, either by MSI, NuGet package or ZIP file, there is supplied documentation that is much richer than the wiki pages.
There is only a console option which has the following options.
-? - show help
or
-target:<path to target> - the target application
the following arguments are optional
-targetdir:<target directory> - the directory to execute the target application in
-targetargs:<target arguments> - the arguments to pass to the target application in
-register[:user] - dynamically register the profiler, use "user" if current user does not have admin rights. Alternatively preregister the profiler using regsvr32.exe
-oldStyle - ONLY use this option if you are encountering MissingMethodExceptionException like errors when the code is run under OpenCover. The issue could be down to ngen /Profile of the mscorlib which then interferes with the instrumentation.
-mergebyhash - used to merge assembly results by their file hash (mainly used for MSTest users)
-output:<output file> - the name of the output file
-filter:<filters> - filters to employ to limit the scope of the coverage. Using PartCover syntax, where (+|-)[Assembly-Filter]Type-Filter
i.e.
+[Open*]* include all types in assemblies starting with Open,
-[*]Core.* exclude all types in the Core namespace regardless of the assembly. If no filters are supplied then the default inclusive filter +[*]* is applied automatically.
NOTE: Multiple filters can be applied by separating them with spaces and enclosing them with quotes i.e. -filter:"+[*]* -[A*]Name.*" .
NOTE: Exclusion filters take precedence over inclusion filters.
-nodefaultfilters - do not apply the default exclusion filters -[System]*, -[System.*]*, -[mscorlib]* and -[Microsoft.VisualBasic]*
-returntargetcode - set the DOS errorlevel to the errrorlevel returned by -target.
Finally the following notes apply to all arguments that may have spaces.
NOTE: If your argument requires spaces then use quotes i.e. -targetargs:"arg1 arg2 arg3"
NOTE: If your argument needs to escape quotes i.e. to pass arguments with spaces to that target process then you can use \"
i.e. -targetargs:"\"c:\program files\" xyz"
NOTE: When using PowerShell and your argument requires spaces then the quotes must be before the argument name i.e. "-targetargs:arg1 arg2 arg3". Interestingly this format can be used for a command file as well.
NOTE: If you are using NUNit to run your tests, NUnit is your target application. The dll that contains the unit tests fro the Application Under Test (AUT) goes in the targetargs argument because NUnit is responsible for running it. Example: OpenCover.Console.exe -target:"C:\Program Files (x86)\NUnit 2.6\bin\nunit-console.exe" -targetargs:"/nologo /noshadow C:\AUT\Ihavethetests.dll" - filter:"+[*]* -[Ihavethetests*]*" -register:user