在IntelliJ IDEA 2017中无法解析@ParameterizedTest

时间:2021-12-12 20:53:51

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:

我是JUnit测试的新手,我想在IntelliJ IDEA 2017.3.3中创建一个参数化测试。所以我添加了JUnit 5:

在IntelliJ IDEA 2017中无法解析@ParameterizedTest

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:

然后IntelliJ下载org.junit.jupiter:junit-jupiter-api:5.0.0。现在,@ Test正在运行,但@ParameterizedTest不是。它说“无法解析符号'ParameterizedTest'”。与@ValueSource相同:

在IntelliJ IDEA 2017中无法解析@ParameterizedTest

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.

PS:还缺少包org.junit.jupiter.params。否则,IntelliJ会自动导入它。

I hope anyone can help me how to fix this. I am not using Maven, Gradle, etc, just Java.

我希望有人可以帮我解决这个问题。我没有使用Maven,Gradle等,只是Java。

1 个解决方案

#1


2  

In article 2.1.2 of JUnit docs, it is mentioned that junit-jupiter-params is a separate artifact containing support for parameterized tests.

在JUnit文档的2.1.2中,提到junit-jupiter-params是一个单独的工件,包含对参数化测试的支持。

In article 3.14, it is explained that the parameterized tests support is currently an experimental feature.

在文章3.14中,解释了参数化测试支持目前是一个实验性功能。

Therefore you need to add the junit-jupiter-params artifact to your dependencies (i.e. Maven or Gradle).

因此,您需要将junit-jupiter-params工件添加到依赖项(即Maven或Gradle)。

#1


2  

In article 2.1.2 of JUnit docs, it is mentioned that junit-jupiter-params is a separate artifact containing support for parameterized tests.

在JUnit文档的2.1.2中,提到junit-jupiter-params是一个单独的工件,包含对参数化测试的支持。

In article 3.14, it is explained that the parameterized tests support is currently an experimental feature.

在文章3.14中,解释了参数化测试支持目前是一个实验性功能。

Therefore you need to add the junit-jupiter-params artifact to your dependencies (i.e. Maven or Gradle).

因此,您需要将junit-jupiter-params工件添加到依赖项(即Maven或Gradle)。