simplecov icon indicating copy to clipboard operation
simplecov copied to clipboard

Simplecov collate not work as expect

Open kewudu opened this issue 3 years ago • 6 comments

I have my own test framework in my project, when I use simplecov to get coverage in the same machine, I can not merge the coverage result, the merged result is empty!

Operation step: (1) run test1 with simplecov, get the following .resultset.json

{
  "pid_34884": {
    "coverage": {
      "C:/aaa/aa/aa.rb": {
        "lines": [
          1,
******
    "timestamp": 1615973314
  }

(2) run test2 with simplecov, get the following .resultset.json

{
  "pid_35136": {
    "coverage": {
      "C:/bb/bb/b.rb": {
        "lines": [
          1,
          1,
********** 
    "timestamp": 1615973421
  }
}

(3) then I put the these two result in two directory: --coverage1     |-- asserts     |-- .last_run.json     |-- .resultset.json     |-- .resultset.json.locl     |-- index.html --coverage2     |-- asserts     |--.last_run.json     |-- .resultset.json     |-- .resultset.json.locl     |-- index.html

(4) in ruby run SimpleCov.collate Dir["coverage*/.resultset.json"], it print: Coverage report generated for pid_34884, pid_35136 to D:/merge/coverage. 0 / 0 LOC (100.0%) covered.

a new coverage directoy created, but the .resultset.json is empty like below:

{
  "pid_34884, pid_35136": {
    "coverage": {
    },
    "timestamp": 1616051300
  }
}

ruby version: ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32] simplecov: simplecov (0.21.2) simplecov-html (0.12.3, 0.10.2) simplecov_json_formatter (0.1.2)

So, is anything wrong in my operation? or I am misunderstand the SimpleCov.collate usage?

kewudu avatar Mar 18 '21 07:03 kewudu

Make sure the code is available in the same location as when the individual coverage reports were generated.

It would be nice if simplecov warned you about this.

jviney avatar Apr 29 '21 09:04 jviney

I encounter this problem too. The path you run SimpleCov.collate must equal to paths in .result.json of other coverages.

danie1Lin avatar Jul 09 '21 03:07 danie1Lin

Make sure the code is available in the same location as when the individual coverage reports were generated.

@jviney Is this really the only solution? Isn't there a way to just merge the .resultset.json files without having to have the entire codebase available?

ddieulivol avatar Aug 10 '23 12:08 ddieulivol