在Jenkins上运行自动测试用例时,java.lang.annotation.AnnotationFormatError

问题描述 投票:2回答:1

我有在Roboelectric框架3.2.2的帮助下编写的测试用例。在本地系统上运行时,我可以运行所有测试用例,但是在Jenkins服务器上运行以覆盖率报告时,它给出以下错误:

java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.robolectric.annotation.Config.application()
    at java.lang.reflect.Method.getDefaultValue(Method.java:612)

我已经尝试从Jenkins删除.Gradle文件夹,但仍然是相同的错误。任何帮助将非常感激。谢谢!

android jenkins robolectric
1个回答
0
投票

[我在Android Studio 3.4.2和compileSdkVersion 28中解决了此问题

我的测试具有此初始配置:

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [Build.VERSION_CODES.O_MR1])
class MyTest {
}

诀窍是将下一行添加到gradle.properties:

android.enableUnitTestBinaryResources=true
© www.soinside.com 2019 - 2024. All rights reserved.