2

I am getting a "cannot resolve symbol Parameter" in the impor. I have to use using junit 4.13, I think this code would work in junit 4.12. What changes can I make to get the following code to work?

import org.junit.Test;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;

@RunWith(Parameterized.class)
public class MyTest {

    @Parameterized.Parameter(0)
    private String arg1;

    @Parameterized.Parameter(1)
    private long arg2;

    public  MyTest(String arg1, long arg2) {
        this.arg1 = arg1;
        this.arg2 = arg2;
    }

    @Parameterized.Parameters
    public static Collection argPairs() {
        return Arrays.asList(new Object[][] {
                {"using arg1", Long.parseLong(arg1) },
                {"using arg2", Long.parseLong(arg2) }
        });
    }

    @Test
    public void test1() {
        // stuff
    }
}

Hemant Patel
  • 3,160
  • 1
  • 20
  • 29
abc123
  • 21
  • 1
  • There are couple of issues in the code. Others can fix the code for you, but its better to fix it yourself. Run the code, see the error and fix it. If you are not able to fix the issue then only post it. – Hemant Patel Sep 15 '20 at 14:37
  • @PratapiHemantPatel turns out I am using junit "4.31" except I just found out it is an internal version of junit (from around 6 years ago). No wonder I couldn't find info on google. The fix was to just remove both "@Parameterized.Parameter" annotations since they were not supported. I realize this question is probably not useful for anyone. Should I delete it or add an accepted answer? – abc123 Sep 15 '20 at 15:03

0 Answers0