如何查看在 IntelliJ 中未通过参数化测试的全套参数?

How to see the full set of parameters that fail a parameterized test in IntelliJ?

我有一个使用 org.junit.runners.Parameterized 的测试 class。如何从 IntelliJ 14 测试中失败的三个参数集中识别出完整的参数集?

左侧的 [1] 是您的参数数组的 index,在您的测试中失败了。因此,转到您的测试 class,查找该测试的参数,第二个([1] 在从零开始的数组中)参数条目是未通过测试的参数。

每组参数都有自己的名字——左边的[1]就是那个名字。

您可以在 @Parameters 中使用 name 参数来自定义该名称,例如:

@Parameters(name = "{index}: testAdd({0}+{1}) = {2}")
public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][]{
            {1, 1, 2},
            {2, 2, 4},
    });
}

这样,在左侧的方括号中,在测试名称旁边,您将看到 [0: testAdd(1+1=2)][1: testAdd(2+2=4)]

默认情况下 name={index},这就是为什么您会在方括号中看到 [0][1]...。