Description
In some threads, specifically this one (#2745, on new Seq module) I was asked by @dsyme and @manofstick to have a look at test coverage.
I'm not 100% sure how to drive this, but let's get the good news out of the way first:
- I've managed to get NCrunch running with the NUnit (and FsCheck etc) tests (this wasn't trivial due to the way FSharp.sln is set up with dependencies that cannot be auto-detected from the prj file)
- Code coverage information is inserted in the editor, which gives immediate feedback over coverage
- Auto-impact analysis and run works (that is: change something in the source and only the impacted tests will be automatically run).
I'm not sure whether this is much different from other testing frameworks, but I hope it helps. Here's some idea of what to expect:
Coverage overview
Coverage per file
In-editor metrics/coverage of non-inline functions:
Red: line belongs to at least one failing test, green: all tests covering that line succeed, white: no tests cover that line or those lines have no debug information that can be used by metrics.
In-editor metrics/coverage of inline functions (not so good):
So, essentially what we are seeing here is:
- Tests seem to cover a large part of FSharp.Core, other projects are barely covered.
- Inline functions are not covered, this is possibly in part because line-timings do not work for some unclear reason (I have to research that, the error thrown says the assembly is invalid after metrics are added, perhaps to do with signature?)
** A bunch of functions seem to be inlined that shouldn't be or don't need to be, they can be disabled with a compile constant for testing / metrics / debugging only
** The missing inline coverage adds up significantly to the coverage reported, we can either exclude these lines or find another way of getting coverage (there are several techniques I use in my own projects) - Execution line-timings coverage is not working, as per above (this would immediately show lines that run unusually long)
I hope this gives some insight. More needs to be done to make this report useful. I don't know if others in this community are using NCrunch (it's commercial), or that I can look into getting coverage with open source tools.
On my todo list (in no particular order and surely incomplete):
- Correct the coverage percentages w.r.t. inlining
- If a change to the code is accepted for this, I can look into fixing inline-coverage
- Perhaps add/report/document the necessary steps for setting this up
- Report issues with failing tests (some are failing because of internationalization issues, others are failing because of timeouts, I'll need to look into each of them)
- Discuss with the community how to drive this further
- Report back to NCrunch on the bugs found in coverage and line-timings