gpt4 book ai didi

android - Powermock 提示在 2 个地方找到 default.properties 文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:57:08 44 4
gpt4 key购买 nike

我正在使用 Robolectric 来测试我的应用程序,我决定使用 Powermock 来模拟静态类和最终类,因此我将以下依赖项添加到我的 build.gradle 文件中:

testImplementation "org.powermock:powermock-module-junit4:1.7.0"
testImplementation "org.powermock:powermock-module-junit4-rule:1.7.0"
testImplementation 'org.powermock:powermock-api-mockito2:1.7.0'
testImplementation 'org.powermock:powermock-classloading-xstream:1.7.0'

然后我开始编写测试,一切正常,除了每个使用 Powermock 的测试也打印以下警告:

Properties file org/powermock/default.properties is found in 2 places: 
ConfigurationSource{location='file:/C:/Users/USUARIO/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-core/1.7.0/19f022747953e7eccc3e53253f709d726931f407/powermock-core-1.7.0.jar!/org/powermock/default.properties}
ConfigurationSource{location='file:/C:/Users/USUARIO/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-core/1.7.0/19f022747953e7eccc3e53253f709d726931f407/powermock-core-1.7.0.jar!/org/powermock/default.properties}
. Which one will be used is undefined. Please, remove duplicated configuration file (or second PowerMock jar file) from class path to have stable tests.Properties file org/powermock/default.properties is found in 2 places:
ConfigurationSource{location='file:/C:/Users/USUARIO/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-core/1.7.0/19f022747953e7eccc3e53253f709d726931f407/powermock-core-1.7.0.jar!/org/powermock/default.properties}
ConfigurationSource{location='file:/C:/Users/USUARIO/.gradle/caches/modules-2/files-2.1/org.powermock/powermock-core/1.7.0/19f022747953e7eccc3e53253f709d726931f407/powermock-core-1.7.0.jar!/org/powermock/default.properties}

. Which one will be used is undefined. Please, remove duplicated configuration file (or second PowerMock jar file) from class path to have stable tests.

每个测试都正确运行,但我想摆脱那个烦人的警告消息。

最佳答案

长话短说;

要修复它,请将“org.powermock.*”添加到@PowerMockIgnore,例如:

@PowerMockIgnore({ "org.powermock.*", "org.mockito.*", "org.robolectric.*", "android.*", "androidx.*" })

在我的例子中,我一直在使用 Roboelectric + PowerMock + Mockito2,但我遇到了同样的问题,因为 PowerMock 自己加载了几次以将所有内容设置为使用另一个 Runner 而不是 PowerMock。

我希望这对某人有帮助:-)

关于android - Powermock 提示在 2 个地方找到 default.properties 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50939258/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com