covered 0.0.1
Processes output of code coverage analysis
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Covered
![License](https://img.shields.io/dub/l/covered.svg)
Covered processes output of code coverage analysis performed by the D programming language compiler (DMD/LDC/GDC).
Usage:
Usage: covered <options> files dirs
Covered processes output of code coverage analysis performed by the D programming language compiler (DMD/LDC/GDC)
Every option below works with any number of files/directories specified in command line.
If nothing is specified, it looks for '*.lst' files in current working directory
Options:
-c --coverage Reports code coverage (default)
-s --source Shows source code, number of executions of each line, and it's code coverage
-b --blame Shows list of files ordered by code coverage
-a --average Reports average code coverage across all passed files
-v --verbose Verbose output
-h --help This help information.
Installation:
$ dub fetch covered # Downloads covered
$ dub run covered # Runs covered
Performing code coverage analysis with DUB:
$ dub -b unittest-cov
This command will build and run your DUB project. Your program will create many *.lst
files in your working dir. Covered uses those files:
$ dub run covered
You can pass aditional options to covered after --
:
$ dub run covered -- --help
Performing code coverage analysis like a pro:
Running dub -b unittest-cov
leads to some problems:
- It pollutes your working directory with tons of
*.lst
files. - Built-in
unittest
s are not that useful. Failedunittest
exits program, so it is impossible to say, how many of them have been failed. - Built-in
assert
s, which are used inunittest
blocks, are not that useful.assert
just throws if value is nottrue
, so it is very hard to say, why assertion failed.
Those problems doesn't make development impossible, but harder and slower.
Moving *.lst
files into separate directory:
Add this code to your app:
version(D_Coverage) shared static this() {
import core.runtime : dmd_coverDestPath;
import std.file : exists, mkdir;
enum COVPATH = "coverage";
if(!COVPATH.exists) // Compiler won't create this directory
COVPATH.mkdir; // That's why it should be done manually
dmd_coverDestPath(COVPATH); // Now all *.lst files are written into ./coverage/ directory
}
Do not forget to add ./coverage
directory into your .gitignore
:
coverage/
Ta-Da! Your working directory is no longer polluted
Use cool unit-testing library
There are lots of them, but I will describe use of unit-threaded.
1. Add entry to dub.json
"configurations": [
{ "name": "executable" },
{
"name": "unittest",
"targetType": "executable",
"preBuildCommands": [
"dub run unit-threaded -c gen_ut_main -- -f .dub/ut.d"
],
"mainSourceFile": ".dub/ut.d",
"dependencies": {
"unit-threaded": "~>0.7.28",
"fluent-asserts": "~>0.6.1"
},
"targetPath": ".dub/",
"targetName": "unittester"
}
],
If you want to use it and move *.lst
into separate directory, copy it's code into some file (cov.d
, for example), and add to your dub.json:
"configurations": [
{ "name": "executable" },
{
"name": "unittest",
....
"sourceFiles": ["cov.d"]
}
],
2. Use it!
$ dub test
Will run unittests with help of unit_threaded. Go to it's documentation for more information.
Use fluent-asserts instead of built-in assertions.
Just use fluent-asserts. And again, go to it's documentation for more.
Put it all together!
$ dub -b unittest-cov -c unittest
Will build and run your application with all *.lst
files moved into ./coverage
directory, unittests runned in parallel, and nice messages if something goes wrong.
$ dub run covered -- ./coverage
That's it! Now you're performing code coverage analysis like a pro! Take a cookie: :cookie:
- Registered by Anton Fediushin
- 0.0.1 released 7 years ago
- AntonMeep/covered
- MIT
- Copyright © 2017, Anton Fediushin
- Authors:
- Dependencies:
- none
- Versions:
-
1.0.2 2019-Mar-17 1.0.1 2018-Jul-08 1.0.0 2018-Jun-20 1.0.0-rc.2 2017-Aug-30 1.0.0-rc.1 2017-Aug-04 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
0 downloads total
-
- Score:
- 0.0
- Short URL:
- covered.dub.pm