IntelliJ 自动配置 Run/Debug 配置使用 TestNG 而不是 Gradle 进行测试

IntelliJ Configuration of Automatic Run/Debug Configuration to use TestNG instead of Gradle for Tests

我有一个复杂的 gradle 项目,为此我手动设置了 Run/Config 配置以用于构建和其他几个任务。

我们使用 TestNG,每当我想 运行 测试时,例如直接在测试方法下方右击

它 运行 是项目的 gradle 测试任务:

=============================================================================
BUILD FAILED (ended at 2020-01-03T16:32:00.670+01:00)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':xxx-xxx:test'.
> No tests found for given includes: [XXXXX](filter.includeTestsMatching)
* Try:
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 https://help.gradle.org
BUILD FAILED in 11s
117 actionable tasks: 4 executed, 113 up-to-date

如果我使用 TestNG 模板手动配置 Run/Debug 配置,它工作正常。

有没有办法配置 IntelliJ 使用 TestNG 运行ner 而不是 gradle 任务?

默认情况下,IntelliJ Idea 使用 Gradle 构建和 运行 测试(对于 Gradle 项目)。 您可以在设置 -> 构建、执行、部署 -> 构建工具 -> Gradle -> 运行 测试中更改此设置

您可以将其更改为 IntelliJ IDEA 以始终选择 TestNG 运行ner 或将其设置为每次测试都选择。这将创建一个 运行 (测试)配置,IDEA 会记住您选择的选项。 为了再次选择,只需删除相应测试的 运行 配置。