Я создаю приложение Java на основе JRE 6. Я использую JUnit 4 для создания параметризованных тестов. Я получаю эту ошибку:
The annotation @Parameterized.Parameters must define the attribute value
в строке, содержащей аннотацию:
@Parameterized.Parameters
Ниже приведен код, который, как мне кажется, имеет отношение к этой проблеме:
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import calc.CalculatorException;
import calc.ScientificCalculator;
@RunWith(Parameterized.class)
public class ScientificCalculatorTest extends BasicCalculatorTest{
/** Provides an interface to the scientific features of the calculator under test */
private ScientificCalculator sciCalc;
private double a, b;
@Before
@Override
public void setUp() throws Exception {
sciCalc = new ScientificCalculator();
//Make sure that the basic functionality of the extended calculator
//hasn't been broken.
theCalc = sciCalc;
}
/**
* Constructor. Is executed on each test and sets the test values to each pair in the data sets.
* @param nr1 the first number in the tested pair.
* @param nr2 the second number in the tested pair.
*/
public ScientificCalculatorTest(double nr1, double nr2){
a = nr1;
b = nr2;
}
@Parameterized.Parameters
public static Collection<Object[]> testGenerator() {
return Arrays.asList(new Object[][] {
//General integer values | -/+ combinations
{ -100, -100},
{ -100, 100},
{ 100, -100},
{ 100, 100}
});
}
Мне удалось найти несколько связанных вопросов, таких как . К сожалению, в моей ситуации они не помогают.
Что я пробовал и не работал:
-
удаление "extends BasicCalculatorTest" из объявления класса
-
добавление тестовых функций, которые используют аннотацию @Test
-
импорт org.junit.runners.Parameterized и использование @Parameters вместо @Parameterized.Parameters
Мне нужно упомянуть, что я использовал очень похожую реализацию (в первую очередь аннотации и testGenerator()) в другом проекте без каких-либо проблем. Реализация следует за учебниками, доступными в Интернете, например this, this и this.
Приветствуется всякая помощь в решении этой ошибки.