Is there a way to calculate code coverage for unit tests for Elm language?
I understand that Elm is compiled into JavaScript and I do can read it for "hello world" type of examples, but code coverage measured for generated JS code is not what I want to see - I want to see code coverage for the original source code lines.
Code coverage is calculated for a file based on the unit tests that SUCCESSFULLY passed. After all the unit tests are run you are able to see either in your browser the exact lines in your code that are being executed or right in your terminal.
Unit tests help to ensure functionality and provide a means of verification for refactoring efforts. Code coverage is a measurement of the amount of code that is run by unit tests - either lines, branches, or methods.
To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.
Code coverage option is available under the Test menu when you run test methods using Test Explorer. The results table shows the percentage of the code executed in each assembly, class, and procedure. The source editor highlights the tested code.
Currently code coverage of Elm source code is not supported. I'm pretty sure that code coverage is one of those non-trivial things that you can't just hack in there quickly.
So I think the best course of action is starting a discussion on the mailing list. The idea will get more attention there, and perhaps someone will be interested in taking it up as a project.
There is a tool that does code coverage for Elm code. It's at https://github.com/zwilias/elm-coverage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With