Reputation: 143
I have a complex gradle project for which I have set up the Run/Config Configuration for the build and for several other tasks manually.
We use TestNG and whenever I want to run a test, e.g. directly by right clicking beneath the test method
it runs a gradle test task for the project:
=============================================================================
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
If I configure the Run/Debug Configuration manually with a TestNG template, it works fine.
Is there a way to configure IntelliJ to use TestNG runner and not the gradle task?
Upvotes: 4
Views: 1335
Reputation: 86
By default IntelliJ Idea uses Gradle to build and run tests (for Gradle projects). You can change this in Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Run tests using
You can either change it to IntelliJ IDEA to always choose the TestNG Runner or set it to choose per test. This will create a run (test) config where IDEA remembers which option you chose. In order to choose again, simply delete the run config for the respective test.
Upvotes: 6