mfbieber
mfbieber

Reputation: 143

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

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

enter image description here

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

Answers (1)

Mr. Tomato
Mr. Tomato

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

screenshot of settings menu

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

Related Questions