JUnit TestSuite

Hi,

I have to test the same application with several configuration. To achieve this goal, I've used in the past jfunc but it's not well recognized in IntelliJ IDEA.

So I've tested the TestSuite adding several instances of the testcase with different configuraiton but I can't make it working.

public class MTest extends TestCase {
public static Test suite() {
    TestSuite suite = new TestSuite("Sample Tests");
    suite.addTest(new ATest(Mode.local));
    suite.addTest(new ATest(Mode.server));

    return suite;
  }

}

I obtain the following exception:


junit.framework.AssertionFailedError
at com.intellij.junit3.TestRunnerUtil$SuiteMethodWrapper.run(TestRunnerUtil.java:259)
at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
at com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

Any Idea?

2 comments
Comment actions Permalink

Hi Stephane,

I suspect that assertion is caused by ATest suite runner. Could you please provide a sample ATest?

Thank you

0
Comment actions Permalink

Hi,

you might be right, I've tried a lot of stuff to workaround and found I guess right way using JUnit4.8.2 in place of JUnit 3.8.1.

As JUnit3.8 reinstanciate the testcases in different classloaders, using the constructor with String parameter (for test name), it don't use the parameters I provided in the suite method.

Anyway with JUnit4 it works fine:

@RunWith(value = Parameterized.class)
public class MyTest {

...

@Parameterized.Parameters
public static Collection<Object[]> data() {
  Object[][] data = new Object[][]{{"local"}, {"server"}};
  return Arrays.asList(data);
}

@Test

public void runTest(){

...

}

}

Thanks

0

Please sign in to leave a comment.