Search code examples
gradleintellij-ideajunitjunit5

Can't find ParameterizedTest and ValueSource


I had done a simple project, trying to understand how ParameterizedTest and ValueSource works.

From the below picture it finds the import path, but it throws an error when I try to run the code:

enter image description here

Also the gradle file:

enter image description here

Here is a link to the entire project.


Solution

  • You need to put junit-jupiter-params in the testCompile source set.

    junit-jupiter-params exports types like @ParameterizedTest and @ValueSource that are needed at compile (and run~) time.

    See also: Missing org.junit.jupiter.params from JUnit5

    Starting with version 5.4.0-M1 JUnit Jupiter provides an aggregator artifact that bundles all available Jupiter-defining artifacts for easy consumption. See https://sormuras.github.io/blog/2018-12-26-junit-jupiter-aggregator.html for details.