test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

Test Coverage for multi module Android app

Open sudansh opened this issue 4 years ago • 3 comments

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?

sudansh avatar Jun 28 '20 08:06 sudansh

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

io-timeout avatar Oct 28 '20 13:10 io-timeout

@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

scottyab avatar Dec 21 '20 13:12 scottyab

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?

trietbui-zalora avatar Sep 03 '21 04:09 trietbui-zalora