Excluding unit tests from external library

强颜欢笑 提交于 2020-04-16 05:44:48

问题


I newly replaced spongyCastle by bouncyCastle in an Android project:

implementation "org.bouncycastle:bcpkix-jdk15on:$project.bouncyCastleVersion"

Since then on Jenkins (our CI) it seems that there are tests being executed from this lib, could this be true? I never saw external libs with units tests executing automatically. The issue is now I see many failed tests, for example:

org.bouncycastle.pqc.crypto.qtesla.QTeslaKeyEncodingTests.testDecodeEncodePrivateKeyQT3P    27 ms   1
 org.bouncycastle.pqc.crypto.qtesla.QTeslaKeyEncodingTests.testDecodeEncodePublicKeyQT3P

Is there a way to exlude al unit tets from an imported library in gradle?


回答1:


To exclude any unit test following can be used in build.gradle:

android {
  testOptions {
    unitTests {
      all {
        //exclude '**/QTeslaKeyEncodingTests.*'
        exclude 'org.bouncycastle/**'
      }
    }
  }
}



回答2:


Try changing your test command to this:

./gradlew --stacktrace testDebug --tests=your.package.name createDebugCoverageReport mergeAndroidReports --continue || true



回答3:


idk if it helps, but I had some issues with my CI related to spongy castle. I solved them by ignoring linting to its packages. In app.gradle, add:

  lintOptions {
    lintConfig file("lint.xml")
  }

lint.xml

<lint>
  <issue id="InvalidPackage">
    <!-- ignore Invalid Package check for spongycastle -->
    <ignore path="**/*spongycastle*.jar"/>
  </issue>
</lint>

My problem was with linting, but you can probably ignore it for testing too.



来源:https://stackoverflow.com/questions/60284462/excluding-unit-tests-from-external-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!