Coverage

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 16 16:45:59 PST 2016


On Tue, 16 Feb 2016 10:35:38 -0200, Leandro Motta Barros via
Digitalmars-d-learn wrote:

> You probably already though of it, but: can't you create a unittest that
> calls your code as many times as desired, passing different input each
> time?

dmd -cov doesn't look specifically at unittests, so another option would 
be to create, effectively, an alternate main() function just for this 
purpose:

int realMain(string[] args) { ... }
int main(string[] args) {
  version(AppCoverage) {
    realMain(["arg1", "arg2"]);
    realMain(["arg3", "arg4"]);
    return 0;
  } else {
    return realMain(args);
  }
}

This only deals with one build configuration, though, which is why it's 
better to be able to combine coverage reports.


More information about the Digitalmars-d-learn mailing list