Note that there are some explanatory texts on larger screens.

plurals
  1. POJava JUnit Parameterized error
    primarykey
    data
    text
    <p>I am creating a Java application based on JRE 6. I use JUnit 4 to generate parameterized tests. I am receiving this error:</p> <pre>The annotation @Parameterized.Parameters must define the attribute value</pre> <p>on the line containing the annotation:</p> <pre><code>@Parameterized.Parameters </code></pre> <p>Below is the code I believe to be relevant to this issue:</p> <pre><code>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&lt;Object[]&gt; testGenerator() { return Arrays.asList(new Object[][] { //General integer values | -/+ combinations { -100, -100}, { -100, 100}, { 100, -100}, { 100, 100} }); } </code></pre> <p>I managed to find some far related questions, such as <a href="https://stackoverflow.com/questions/7594582/annotation-attributes-with-type-parameters">this</a>. Sadly, in my situation they're of no help. </p> <p>What I have tried and didn't work: </p> <ul> <li><p>removing the "extends BasicCalculatorTest" from the class declaration</p></li> <li><p>adding test functions that use the @Test annotation</p></li> <li><p>importing org.junit.runners.Parameterized and using @Parameters instead of @Parameterized.Parameters</p></li> </ul> <p>I need to mention that I have used a very similar implementation (most notably the annotations and testGenerator()) in another project without any issues. The implementation follows the tutorials available online, such as <a href="http://isagoksu.com/2009/development/agile-development/test-driven-development/using-junit-parameterized-annotation/" rel="nofollow noreferrer">this</a>, <a href="http://www.mkyong.com/unittest/junit-4-tutorial-6-parameterized-test/" rel="nofollow noreferrer">this</a> and <a href="https://blogs.oracle.com/jacobc/entry/parameterized_unit_tests_with_junit" rel="nofollow noreferrer">this</a>.</p> <p>Any help on solving this error is greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload