Java 重载的参数化测试运行程序无法与JUnit4Provider一起使用

Java 重载的参数化测试运行程序无法与JUnit4Provider一起使用,java,junit,junit4,parameterized,surefire,Java,Junit,Junit4,Parameterized,Surefire,我正在使用以下测试运行程序: 它所做的是将参数化测试的名称更改为更具可读性。ie:预期结果-“myDefinedTestName” 当我使用eclipse运行时,它工作正常:我可以看到新名称。 当我使用以下命令运行时: 事实并非如此。ie:我得到了“oldTestName[0]”。没有错误。为什么以及如何解决这个问题 我尝试过使用JUnitCore,但没有成功。我已经做了以下工作: 测试者 import org.junit.runner.JUnitCore; public class Tes

我正在使用以下测试运行程序:

它所做的是将参数化测试的名称更改为更具可读性。ie:预期结果-“myDefinedTestName”

当我使用eclipse运行时,它工作正常:我可以看到新名称。 当我使用以下命令运行时:

事实并非如此。ie:我得到了“oldTestName[0]”。没有错误。为什么以及如何解决这个问题


我尝试过使用JUnitCore,但没有成功。我已经做了以下工作:

测试者

import org.junit.runner.JUnitCore;

public class TestRunner {

/**
 * @param args
 */
public static void main(final String[] args) {
    final JUnitCore provider = new JUnitCore();
    provider.addListener(new TestJUnitCore4Listener());
    provider.run(UpdateBackgroundImageParameterizedTests.class);

}

}
听众

import org.junit.runner.Description;
import org.junit.runner.notification.RunListener;

public class TestJUnitCore4Listener extends RunListener {

    @Override
    public void testFinished(final Description description) throws Exception {
         System.out.println(description.getDisplayName() + " "
            + description.getMethodName());
    }

}
测验


当用作测试运行程序时,同样的代码也起作用。所以问题一定出在JUnit4提供者来自哪里?它给出了什么错误?您如何使用提供程序运行代码?你能再给我一点背景吗?
import org.junit.runner.Description;
import org.junit.runner.notification.RunListener;

public class TestJUnitCore4Listener extends RunListener {

    @Override
    public void testFinished(final Description description) throws Exception {
         System.out.println(description.getDisplayName() + " "
            + description.getMethodName());
    }

}
import static org.junit.Assert.assertTrue;

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

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;

@RunWith(LabelledParameterized.class)
public class UpdateBackgroundImageParameterizedTests {

// Fields
private final String datum;
private final String expectedResult;

/**
 * Constructor is called for every parameter set in generateData()
 * 
 * @param datum
 *            input to be used in tests
 * @param expectedResult
 *            output expected by tests
 */
public UpdateBackgroundImageParameterizedTests(final String datum,
        final String expectedResult) {
    super();
    this.datum = datum;
    this.expectedResult = expectedResult;
}

/**
 * @return a list of expected inputs and outputs
 */
@Parameters
public static Collection<Object[]> generateData() {
    return Arrays.asList(new Object[][] { { "sunny", "a" }, // 0
            { "cloudy", "a" }, // "a"
            { "rain", "a" }, // 2
            { "heavy snow", "a" }, // 3
            { "occasionally thundery", "a" }, // 4
            { "clear skies", "a" }, // 5
            { "error", "a" } }); // 6
}

/**
 * Test updateBackgroundImage using parameter injection for feed Test run
 * for all parameters specified in generateData()
 * 
 * @throws Exception
 */
@Test
public void testUpdateBackgroundImage() throws Exception {
    assertTrue(true);
}

}
testUpdateBackgroundImage[0](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[0]
testUpdateBackgroundImage[1](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[1]
testUpdateBackgroundImage[2](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[2]
testUpdateBackgroundImage[3](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[3]
testUpdateBackgroundImage[4](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[4]
testUpdateBackgroundImage[5](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[5]
testUpdateBackgroundImage[6](UpdateBackgroundImageParameterizedTests) testUpdateBackgroundImage[6]