Setting up to run a TestSuite in #9833

I want to setup a Junit run configuration that points to a JUnit 3 TestSuite

Here is the class I am trying to run

public class LEISS1TestSuite {
private static TestSuite leissOneTestSuite;
public static Test suite() {
  leissOneTestSuite = new TestSuite();
  leissOneTestSuite.addTest(new DoStructuredSearchTest());
  leissOneTestSuite.addTest(new DoTextSearchTest());
  return leissOneTestSuite;
}
I have tried running this as a JUnit, an Application, and just right clicking on the class
and selecting run each fails
I receive:

junit.framework.AssertionFailedError: TestCase.fName cannot be null
at com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:22)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


Currently there is no help in IntelliJ  that mentions using TestSuite,
When I searched the forum the documents they referred to no longer exist:
E.g:http://www.jetbrains.net/devnet/message/5156032 referres to non existant help.

Can anyone provide pointers on how to do this ?

6 comments
Comment actions Permalink

Hello Rob,

public class LEISS1TestSuite {
private static TestSuite leissOneTestSuite;
public static Test suite() {
leissOneTestSuite = new TestSuite();
leissOneTestSuite.addTestSuite(DoStructuredSearchTest.class);
leissOneTestSuite.addTestSuite(DoTextSearchTest.class);
return leissOneTestSuite;
}

should work


Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

I want to setup a Junit run configuration that points to a TestSuite

Here is the class I am trying to run

public class LEISS1TestSuite {
private static TestSuite leissOneTestSuite;
public static Test suite() {
leissOneTestSuite = new TestSuite();
leissOneTestSuite.addTest(new DoStructuredSearchTest());
leissOneTestSuite.addTest(new DoTextSearchTest());
return leissOneTestSuite;
}
I have tried running this as a JUnit an Application, and just right
clicking on the class
and selecting run each fails
I receive:
junit.framework.AssertionFailedError: TestCase.fName cannot be null
at
com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.ja
va:94)
at
com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(Ide
aTestRunner.java:22)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JU
nitStarter.java:118)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40
)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Currently there is no help in IntelliJ that mentions using TestSuite,
When I searched the forum the documents they referred to no longer
exist: E.g:http://www.jetbrains.net/devnet/message/5156032 referres to
non existant help.

Can anyone provide pointers on how to do this ?

---
Original message URL:
http://www.jetbrains.net/devnet/message/5237447#5237447



0
Comment actions Permalink

Hello Rob,

From junit.framework.TestCase javadoc:
/**

  • The tests to be run can be collected into a TestSuite. JUnit provides

  • different <i>test runners</i> which can run a test suite and collect the

results.

  • A test runner either expects a static method <code>suite</code> as the

entry

  • point to get a test to run or it will extract the suite automatically.

  • <pre>

  • public static Test suite() {

  • suite.addTest(new MathTest("testAdd"));

  • suite.addTest(new MathTest("testDivideByZero"));

  • return suite;

  • }

**/

Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

I want to setup a Junit run configuration that points to a TestSuite

Here is the class I am trying to run

public class LEISS1TestSuite {
private static TestSuite leissOneTestSuite;
public static Test suite() {
leissOneTestSuite = new TestSuite();
leissOneTestSuite.addTest(new DoStructuredSearchTest());
leissOneTestSuite.addTest(new DoTextSearchTest());
return leissOneTestSuite;
}
I have tried running this as a JUnit an Application, and just right
clicking on the class
and selecting run each fails
I receive:
junit.framework.AssertionFailedError: TestCase.fName cannot be null
at
com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.ja
va:94)
at
com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(Ide
aTestRunner.java:22)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JU
nitStarter.java:118)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40
)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Currently there is no help in IntelliJ that mentions using TestSuite,
When I searched the forum the documents they referred to no longer
exist: E.g:http://www.jetbrains.net/devnet/message/5156032 referres to
non existant help.

Can anyone provide pointers on how to do this ?

---
Original message URL:
http://www.jetbrains.net/devnet/message/5237447#5237447



0
Comment actions Permalink

Since I don't see a difference between what I wrote and the JavaDoc you posted am I to assume this could be a bug in IntelliJ ?

0
Comment actions Permalink

Hello Rob,

No, there is no bug here. There is the difference in name of the test: suite.addTest(new
MathTest("testAdd"));

constructor without parameters is not good:
/**

  • No-arg constructor to enable serialization. This method

  • is not intended to be used by mere mortals without calling setName().

*/
public TestCase() {
fName= null;
}

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Since I don't see a difference between what I wrote and the JavaDoc
you posted am I to assume this could be a bug in IntelliJ ?

---
Original message URL:
http://www.jetbrains.net/devnet/message/5237543#5237543



0
Comment actions Permalink

For documentation the following works:

public class LEISS1TestSuite {
private static TestSuite leissOneTestSuite;

public static Test suite() {
  leissOneTestSuite = new TestSuite();
  leissOneTestSuite.addTest(new TestSuite(DoStructuredSearchTest.class));
  leissOneTestSuite.addTest(new TestSuite(DoTextSearchTest.class));
    // All methods starting with "test" will be executed in the test suite.
  return leissOneTestSuite;
}
}

0
Comment actions Permalink

This has uncoverd a problem in IntelliJ that is related to the handling of modules, and class paths.
It is similar to several other Jira reports I filed related to classpath problem and multiple modules, and all but one of these have been fixed.

For example Anna you fixed  http://www.jetbrains.net/jira/browse/IDEADEV-35664 which is closely related.

Essentially, I set the Junit run configuration to use module A class path and start in the root of module A's directory and point it at the TestSuite class conatined in module A.
However model B also had a JUnit with the same classpath and the test runner incorrectly runs the tests from Module B.


I am repeating the request that I made in that JIRA report:

I would love to see a Meta-Issue opened up to cover better support for modules in IJ 9.0.
I have filed a number of bugs in refactoring, unit tests and maven support that seem to

happen because IJ has a loosely defined model for modules.

I recall a year ago 'Dmitry Jemerov' stating that IJ would not model its support of modules

after eclipses 'projects'. I am wondering now if a compromise between IJ 8.0 modules and

eclipses 'projects' might be consider for IJ 9.0.
My speculation is that a stronger model/api for modules could simplify the IJ code base

by refactoring out duplicate code from various places.
Thanks in advance for your consideration and time.



-Rob

0

Please sign in to leave a comment.