I'm new to JUnit testing and I would like to create a parameterized test in IntelliJ IDEA 2017.3.3. So I added JUnit 5:
Then IntelliJ downloaded org.junit.jupiter:junit-jupiter-api:5.0.0
. Now, @Test
is working, but @ParameterizedTest
is not. It says "Cannot resolve symbol 'ParameterizedTest'". It's the same with @ValueSource
:
Code:
import org.junit.jupiter.api.*;
class SSTest {
@ParameterizedTest
@ValueSource(ints = {1, 2, 3})
void testSlowSort(int arg) {
}
@Test
void testSort() {
}
}
PS: Also the package org.junit.jupiter.params
is missing. Otherwise, IntelliJ would import it automatically.
I hope anyone can help me how to fix this. I am not using Maven, Gradle, etc, just Java.
In article 2.1.2 of JUnit docs, it is mentioned that junit-jupiter-params
is a separate artifact containing support for parameterized tests.
In article 3.14, it is explained that the parameterized tests support is currently an experimental feature.
Therefore you need to add the junit-jupiter-params
artifact to your dependencies (i.e. Maven or Gradle).
use below import statement [Intellisense should bring those imports automatically]
import org.junit.jupiter.params.ParameterizedTest
Add following dependencies to your build.gradle.kts [for gradle builds]
testImplementation("org.junit.jupiter:junit-jupiter-params:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-params:5.6.2")
Build project and @ParameterizedTest
annotation should be available. If not, then restart IntelliJ and libraries should be loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With