JRE 6을 기반으로 Java 응용 프로그램을 작성하고 있습니다. JUnit 4를 사용하여 매개 변수화 된 테스트를 생성합니다. 주석이 포함 된 줄에Java JUnit 매개 변수화 된 오류
The annotation @Parameterized.Parameters must define the attribute value
: :이 오류가 발생하고 I가 관리
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}
});
}
: 아래
@Parameterized.Parameters
을 나는이 문제와 관련된 생각하는 코드입니다 this과 같이 멀리 관련 질문을 찾아보십시오. 슬프게도, 제 상황에서는 도움이 안됩니다.
나는 시도하고 작동하지 않았다 일 :이 클래스 선언
@Test 주석을 사용하는 추가 테스트 기능에서 "BasicCalculatorTest를 확장"제거
org.junit.runners.Parameterized를 가져오고 @ Parameterized.Parameters 대신 @Parameters를 사용합니다.
필자는 다른 프로젝트에서 아주 비슷한 구현 (특히 주석과 testGenerator())을 아무 문제없이 사용했다는 것을 언급해야합니다. 구현은 this, this 및 this과 같이 온라인에서 사용할 수있는 자습서를 따릅니다.
이 오류를 해결하는 방법에 대한 도움을 주시면 감사하겠습니다.
'@ Parameterized.Parameters (value =/* required here * /)'오류는 'value'속성은 필수 항목입니다. –
@PaulBellora, 그냥 오타였습니다. 지적 해 주셔서 감사합니다. 문제를 해결했지만 문제는 여전히 남아 있습니다. –
@ BheshGurung, 나는 그것을 말하고 있지만 다른 프로젝트에서는 (value =/* 여기에 * 필요함) 사용했지만 제대로 작동했습니다. 또한, 내가 사용하는 튜토리얼은 이것을 사용하지 않습니다. –