opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
50 stars 39 forks source link

Test coverage for the Quest module not generated correctly. #3055

Open ndegwamartin opened 4 months ago

ndegwamartin commented 4 months ago

Describe the Issue The command used on main branch fails on this branch with the following error

Command:

./gradlew -PlocalPropertiesFile=local.properties :quest:clean && ./gradlew -PlocalPropertiesFile=local.properties :quest:assembleOpensrpDebugAndroidTest --stacktrace && /Users/runner/Library/Android/sdk/platform-tools/adb install quest/build/outputs/apk/androidTest/opensrp/debug/quest-opensrp-debug-androidTest.apk && ./gradlew -PlocalPropertiesFile=local.properties :quest:assembleOpensrpDebug --stacktrace && /Users/runner/Library/Android/sdk/platform-tools/adb install quest/build/outputs/apk/opensrp/debug/quest-opensrp-debug.apk && /Users/runner/Library/Android/sdk/platform-tools/adb shell am instrument -w -e package org.smartregister.fhircore.quest.ui.profile -e coverage "true" org.smartregister.opensrp.test/org.smartregister.fhircore.quest.QuestTestRunner && /Users/runner/Library/Android/sdk/platform-tools/adb shell run-as org.smartregister.opensrp cat "/data/user/0/org.smartregister.opensrp/files/coverage.ec" > quest/coverage.ec && ./gradlew -PlocalPropertiesFile=local.properties :quest:fhircoreJacocoReport --stacktrace

Error

Error: Failed to generate Emma/JaCoCo coverage. Is Emma/JaCoCo jar on classpath?
Generated code coverage data to /data/user/0/org.smartregister.opensrp/files/coverage.ec
cat: /data/user/0/org.smartregister.opensrp/files/coverage.ec: No such file or directory
Error: The process '/bin/sh' failed with exit code 1

Enabling test coverage in the build file using the following debug configs results in the error logged here

android {
    ...
    buildTypes {
      debug {
          enableAndroidTestCoverage = true
          enableUnitTestCoverage = true
     }
        ...
    }
}

The specific error that emerged after this upgrade is

Caused by: java.io.IOException: Error while instrumenting org/hl7/fhir/r5/formats/JsonParser.class with JaCoCo 0.8.11.202310140853/f33756c.
    at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:161)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:111)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:136)
    ... 123 more
Caused by: org.objectweb.asm.ClassTooLargeException: Class too large: org/hl7/fhir/r5/formats/JsonParser
    at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:622)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:92)
    at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:109)
ndegwamartin commented 4 months ago

The related PR that introduced the issue is Upgrade sdk libraries to latest versions #2825