codeclimate / test-reporter

Code Climate Test Reporter
MIT License
156 stars 76 forks source link

Test Coverage for multi module Android app #434

Open sudansh opened 4 years ago

sudansh commented 4 years ago

I am using Jacoco to produce test results for multi module app. The modular structure for example is app/src/main/java module1/src/main/java module2/src/main/java... In the test coverage recent report, I could only see the files under app/src/main/java being tracked. How could I combine all modules?

io-timeout commented 4 years ago

Possibly related to https://github.com/codeclimate/test-reporter/issues/376

scottyab commented 3 years ago

@sudansh The cc-test-reporter tool supports summing the coverage files from multi repositories. We have 3 modules /app /api and /data. We call format-coverage for each of the jacoco.xml report files then sum-coverage. Note this is extracted form Travis.yml file.

Don't know if it's expected or if there's a better way but I found we have to set the JACOCO_SOURCE_PATH environment var before formatting the coverage.


- export JACOCO_SOURCE_PATH=api/src/main/java/
  - ./cc-test-reporter format-coverage ./api/build/reports/jacoco/release/jacoco.xml --input-type jacoco -o coverage.api.json
  - export JACOCO_SOURCE_PATH=app/src/main/java/
  - ./cc-test-reporter format-coverage ./app/build/reports/jacoco/myFlavourRelease/jacoco.xml --input-type jacoco -o coverage.app.json
  - export JACOCO_SOURCE_PATH=data/src/main/java/
  - ./cc-test-reporter format-coverage ./data/build/reports/jacoco/release/jacoco.xml --input-type jacoco -o coverage.hstml.json

  # sum the modules
  - ./cc-test-reporter sum-coverage coverage.*.json -p 3 -o codeclimate.total.json
  - ./cc-test-reporter upload-coverage -i codeclimate.total.json
trietbui-zalora commented 3 years ago

I wonder why do we need to specify export JACOCO_SOURCE_PATH=app/src/main/java/? Does the ./api/build/reports/jacoco/release/jacoco.xml already has enough info about it?