nette / tester

Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏
https://tester.nette.org
Other
464 stars 71 forks source link

CodeCoverage always appends data #105

Closed milo closed 10 years ago

milo commented 10 years ago

CodeCoverage always appends data to coverage.dat file. But this file may exist from previous run and data may be outdated. In the result the coverage-reports generates nonsences.

Maybe related to #103.

milo commented 10 years ago

Propose Runner already sets env var NETTE_TESTER_RUNNER=1. It will be changed to Runner's PID. NETTE_TESTER_RUNNER=$pid. CodeCoverage::save() checks this env var. If not exists or not match, whole coverage.dat will be replaced.

Note It will not work when Runner is instantized and used in test (e.g. Tester's tests). So NETTE_TESTER_RUNNER env var could inherit.

dg commented 10 years ago

What about storing and checking filemtime in Collector::save()?

milo commented 10 years ago

It may lie when test will be changed, e.g. some assertions will be removed but code stay marked as coveraged.

Or situation: first run tester Nette, second run tester Nette\Database. First run fills coverage.dat, second only Database files and coverage-report show coveraged whole framework even last run against Database only.

This appending can be desired. Make it configurable by Collector::save($file, $append = FALSE)?

dg commented 10 years ago

Yeah, I understand. Checking filemtime may be useful for ReportGenerator to ensure that the coverage.dat corresponds with files.

And about appending/replacing: It might be interesting to add the option for generating code coverage directly to the Tester. Path to coverage.dat should be passed via environment variable, it will be started automatically in Environment::setup and in this case it will switch to append mode.

After that Tester can generate HTML output.

dg commented 10 years ago

Closing, it is a feature ;-) https://github.com/nette/tester/pull/106#issuecomment-36789858