【发布时间】:2023-03-05 21:19:01
【问题描述】:
我的 gradle 失败:
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
案例描述:
- 附加到项目代码库的下一个库:
APP/build.gradle
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
-
更新了 gradle-wrapper.properties
distributionUrl=https....gradle-4.4-all.zip 到 4.7-all
在所有 gradle 构建成功之后
-
创建了测试类
@TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestClass { @Test internal fun testName() { Assert.assertEquals(2, 1 + 1) } } 使用命令行参数
./gradlew --warning-mode=all运行 Gradle 构建,以查看已弃用的功能到底是什么。
因此,我无法构建应用程序,并且收到了 FAILURE: 消息。
【问题讨论】:
-
这不是失败。该应用程序仍然可以编译,不是吗?
-
应用程序编译时出现相同的失败消息。 :-(
-
这不是失败。如果应用程序没有编译,那将是失败的。这充其量只是一个警告。
-
@EpicPandaForce 不幸的是,正如我所提到的,这是一条失败消息。问题不在于如何解释信息,而是我对您的影响表示赞赏。
-
试试这个解决方案。只需添加一些代码。 stackoverflow.com/questions/54276381/…
标签: android unit-testing gradle kotlin junit5