有没有办法使用Gradle运行特定的Android单元测试?我试过了
gradle -Dtest.single=UnitTestName connectedInstrumentTest
Run Code Online (Sandbox Code Playgroud)
但它似乎在包中运行所有测试.
提前谢谢,伊万.
在我的 Android 应用程序中,我有几个测试类。如果我运行以下命令,./gradlew connectedAndroidTest它将运行 android test 文件夹中的所有测试用例并为所有测试类生成测试报告,但我需要测试特定的测试类并为我尝试使用以下命令的测试类生成报告:
./gradlew test --tests com.login.user.UserLoginTest
Run Code Online (Sandbox Code Playgroud)
上面的命令抛出以下异常
FAILURE: Build failed with an exception.
* What went wrong:
Problem configuring task :app:test from command line.
> Unknown command-line option '--tests'.
* Try:
Run gradlew help --task :app:test to get task usage details. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at …Run Code Online (Sandbox Code Playgroud) android unit-testing android-gradle-plugin android-instrumentation android-junit
我需要使用命令行在快速文件中的应用程序的特定包中使用 Gradle 运行测试。我正在使用这个命令
sh './gradlew test --tests "com.package.exemple.*"'
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误
从命令行配置任务 :app:test 时出现问题。
>未知的命令行选项“--tests”。
我尝试了很多变体,但没有一个有效。
感谢您的帮助 !