-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
A helpful feature for C# contract tests would be an easier way to collect code coverage for the original contract source from the neo-test execution.
@devhawk provided some insightful information regarding this:
TestApplicationEngine automatically collects coverage information while
executing. You can retrieve it via the GetHitMap and GetBranchMap methods
The Get*Map methods take a contract hash parameter - coverage information
is tracked separately per contract
The hit map is a dictionary mapping NeoVM addresses to a hit count (i.e.
how many times that specific instruction was executed)
the branch map is a dictionary mapping NeoVM addresses of branch instructions
to a pair of hit counts - how many times this instruction branched vs continued
So that's the good news. Bad news is that there is no built-in mechanism to
aggregate the info or publish it in a format that existing code coverage tools
can use
There's also a need to map NeoVM address to source code lines. I assume folks
are more interested in a source level view of coverage rather than an assembly
level view
There is code in the test runner project (part of the neo test repo, a tool to
enable non-c# developers to run tests) that iterates sequence points from debug
info to retrieve hit/branch coverage info, but it's not in an easy-to-reuse
method, it's just part of WriteResultsAsync method.
devhawk
Metadata
Metadata
Assignees
Labels
No labels