JRE 6に基づいてJavaアプリケーションを作成しています。JUnit 4を使用してパラメータ化されたテストを生成します。私が管理しJava JUnitパラメータ化エラー
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
以下
:注釈を含む行の
The annotation @Parameterized.Parameters must define the attribute value
:私はこのエラーが発生しますthisのような関連性の高い質問を見つけます。残念ながら、私の状況では彼らは役に立たない。
私が試みていると動作しませんでした何:クラス宣言
@Testアノテーションを使用する追加のテスト機能から "BasicCalculatorTestを拡張し、" 削除
@ Parameterized.Parametersの代わりにorg.junit.runners.Parameterizedをインポートして@Parametersを使用する
私は非常によく似た実装(主に注釈とtestGenerator())を問題なく他のプロジェクトで使用したことに言及する必要があります。実装は、this,this、thisなど、オンラインで入手できるチュートリアルに従います。
このエラーを解決するための助けがあれば幸いです。
'@ Parameterized.Parameters(value =/* required here * /)'というエラーは、属性 'value'は必須です。 –
@PaulBellora、それはちょうどタイプミスでした、それを指摘してくれてありがとう、私はそれを修正しましたが、問題はまだ残っています。 –
@BheshGurung、私はそれは言うが、私は別のプロジェクト(値=/*ここに必要* /)でそれを使用して、それはうまくいきました。また、私がリンクしているチュートリアルのどれもこれを使用していません。 –