A statement: IntelliJ IDEA likes JUnit. Thing is, it’s gonna try to use JUnit even if you create a test with TestNG selected in settings. When you are ready to run your tests, you are probably about to encounter the following error:
Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6. Here is what needs to be done in this case:
- (optional) Add TestNG as Gradle dependency. At this moment you probably have it added by pressing ‘Fix’ button in ‘Create test’ dialog window. This is not a required step, I just prefer to have all the dependencies in one place.
- Explicitly tell Gradle to use TestNG as a testing framework.
Here’s how the modified build.gradle will look like:
apply plugin: 'java'