This project is read-only.

Code Coverage for Windows Service Runs using System Account

Jul 22, 2015 at 7:48 AM
I am trying to use OpenCppCoverage for a Windows Service which runs using System Account. How can I use command line?
Jul 22, 2015 at 10:37 PM

Interesting use case.

"you cannot immediately run a service or step into its code. Instead, you must install and start your service, and then attach a debugger to the service's process"

As you cannot attach OpenCppCoverage to a running process, I am not sure it is possible to run OpenCppCoverage for a service.

As a workaround, if it is possible for you, you can split your service into 3 projects:
  • Library projects: Contains all your code
  • Service project: Contains only the code specific for the service
  • Console project: Contains only main function that call your library
In this way, it will also be easier for debugging your service.

I will still investigate deeper in Window Service and give you more feedback.

Hope that help,

Aug 2, 2015 at 11:16 AM

As a service is run directly by the system (service.exe), you cannot run OpenCppCoverage on a service.
In the same idea as the workaround in the previous message, you can add a command line argument that runs directly the code of your service and skips the service initialization parts.

Hope that help,

Marked as answer by OpenCppCoverage on 11/15/2015 at 3:37 AM