ben parametreli testler oluşturmak için JUnit 4 kullanın JRE 6. dayanan bir Java uygulaması oluşturma. Ek açıklama içeren satırdaJava JUnit Parameterized hatası
The annotation @Parameterized.Parameters must define the attribute value
: Ben bu hatayı alıyorum ben başardı
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}
});
}
: Aşağıda
@Parameterized.Parameters
bu konuyla ilgili olduğuna inandığımız koddur this gibi bazı ilgili soruları bulabilirsiniz. Ne yazık ki, benim durumumda hiçbir yardımı yok.
denedim ve işe yaramadı Ne: Sınıf bildirimi
@Test notu kullanın ekleyerek test fonksiyonları gelen "BasicCalculatorTest uzanır" çıkarmadan
org.junit.runners.Parameterized ithal ve @Parameters yerine @ Parameterized.Parameters kullanılarak
Başka bir projede herhangi bir sorun yaşamadan çok benzer bir uygulama kullandığımı (özellikle notları ve testGenerator()) kullandığımı belirtmem gerekir. uygulama böyle this, this ve this olarak online eğitimlerimizi takip eder.
bu hatayı çözme üzerinde herhangi bir Yardım büyük takdir edilmektedir.
'@ Parameterized.Parameters (value =/* required here * /)' error, "value" özniteliğinin zorunlu olduğunu belirtir. –
@PaulBellora, sadece bir yazım hatası oldu, o işaret için teşekkürler, bu sorunu giderdim ama sorun hala devam etmektedir. –
@BheshGurung, bunu söylediğini biliyorum ama bunu başka bir projede kullanmadan kullandım (value =/* burada */gerekir) ve iyi çalıştı. Ayrıca, bağladığım eğiticilerin hiçbiri bunu kullanmıyor. –