I'm having trouble running a Parameterized
Groovy JUnit test-case in Eclipse (see below for test code and environment details).
Symptoms
Things I've tried
So
So I have an inconvenient workaround (3). But this isn't scalable, as this test-case still won't be included when I run all test-cases in the project.
Any ideas how I can get Eclipse/Groovy plugin/JUnit to automatically recognise my test-case?
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
@RunWith(Parameterized)
public class TestParams {
final int a
public TestParams(int a) { this.a = a }
@Parameters
public static Collection<Object[]> data() {
def cases = new Object[2][1]
cases[0][0] = 3
cases[1][0] = 4
Arrays.asList(cases)
}
@Test public void test() { println "a = $a" }
}
Environment
this code works on my juno eclipse, junit 4.10 and groovy 2.0.6. i started with your code, but had to fool around with the imports as some of the annotations were red. i also had to add the .class to parameterized.
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
@RunWith(Parameterized.class) public class TestParams {
final int a
public TestParams(int a) { this.a = a }
@Parameters
public static Collection<Object[]> data() {
def cases = new Object[2][1]
cases[0][0] = 3
cases[1][0] = 4
Arrays.asList(cases)
}
@Test public void test() { println "a = $a" }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With