相关疑难解决方法(0)

缺少来自JUnit5的org.junit.jupiter.params

我正在尝试将参数化测试添加到我的Java程序中.我找到了JUnit 5的例子,我确实包含了这些例子.

https://blog.codefx.org/libraries/junit-5-parameterized-tests/

问题是我无法添加@ParameterizedTest,因为缺少命名空间.Idk为什么或如何.

文档页面中明确指出它是在org.junit.jupiter.params,但我没有那个.

为了让您了解我的代码:

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.jupiter.api.Assertions.*;

class SubsetPrinterTest
{
    // https://blog.codefx.org/libraries/junit-5-parameterized-tests/

    static Collection<Object[]> makeSetData()
    {
        return Arrays.asList(new Object[][]
        {
                {1, new char[]{'1'}},
                {2, new char[]{'1', '2'}},
                {3, new char[]{'1', '2', '3'}},
                {4, new char[]{'1', '2', '3', '4'}},
                {5, new char[]{'1', '2', '3', '4', '5'}}
        });
    }

    // This should be a parameterized test using the makeSetData.
    @Test
    void makeSet()
    {
        // Arrange
        SubsetPrinter subsetPrinter = new SubsetPrinter();

        // Act …
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing junit5

11
推荐指数
1
解决办法
6047
查看次数

标签 统计

java ×1

junit ×1

junit5 ×1

unit-testing ×1