How do code coverage tools work?

前端 未结 5 1357
小蘑菇
小蘑菇 2021-01-30 08:43

How do code coverage tools like NCover know what parts of the code were executed and what parts were not?

5条回答
  •  野性不改
    2021-01-30 09:12

    From this source:

    NCover uses the .NET Framework profiler API to monitor an application's execution. When a method is loaded by the CLR, NCover retrieves the IL and replaces it with instrumented IL code

    So in short, it hooks itself into the just-in-time compilation.

    Not all tools work the same way though. Other tools work by modifying the bytecode of your application after the code has been compiled.

提交回复
热议问题