3

We have an app, and the server is wrote in PHP.

Now I want to get the php code coverage for the manual testing team, thus help them improve their work.

The php code coverage looks good, the usage is as below:

$coverage = new PHP_CodeCoverage;
$coverage->start('<name of test>');

// do the testing

$coverage->stop();

$writer = new PHP_CodeCoverage_Report_Clover;
$writer->process($coverage, '/tmp/clover.xml');

But if a method has 3 branches, every time I send a request, there will be a report showing the coverage is 1/3. But what I want is to have a report for all my manual testing requests, is there a way to get it?

Or just have one report for each request, and then merge them.

2 Answers2

1

If your test code is written in PHP, you can write them as Unit Tests. Unit Tests will help to structure your tests better, but you can also define multiple test suites. So if you have your three different tests, or your three different test suites, you can have them run all at once. Furthermore, if you have them running all at once, you can have them run and generate code coverage for all tests run.

This also has really nice integration with phpStorm that will show your coverage in the IDE, and highlight lines that aren't covered.

But, if you don't want to use PHPUnit, and just want to merge multiple clover.xml files, this question has already been answered

Community
  • 1
  • 1
Gareth Parker
  • 5,012
  • 2
  • 18
  • 42
  • My demand is to get the code coverage for manual testing, the testing team is working on the phones. So the unit test method seems not satisfy. – Bradley Cheng Aug 17 '16 at 15:00
0

Our PHP Test Coverage Tool will collect test coverage regardless of how it is invoked.

This means you can invoke with unit tests, or manually, or in any combination you see fit.

You can ask it to take a snapshot of the coverage at any point by invoking a PHP external script. To get coverage on a per manual operation, simply run your program manually, and take a snapshot after each manual operation. Each step will produce seperate test coverage data, which you can display in the GUI by itself. The display tool GUI will also combine multiple coverage data files to provide coverage information for the set of activities those files represent. No special code or procedures to glue coverage files are needed.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341