Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse, and JUnit. Tests passing/failing depending on where they are run from?
    primarykey
    data
    text
    <p>Hello I have a problem that is driving me crazy. I have created a unit test that tries to instantiate an object. If it cannot, it throws an exception</p> <pre><code> try{ testObject = new Target(2,4,true); } catch(Exception e){ AssertionError ae = new AssertionError("Unable to create a target"); ae.initCause(e); throw ae; } </code></pre> <p>I have then placed this into a JUnit test suite. If I select the suite, or the test by itself and click run, I get no problems.</p> <p>On the other hand, in Eclipse IDE, if I right click the entire project folder and click run JUnit tests, the tests that were passing are now giving me errors such as indexoutofbounds. This test doesn't access any external files? so how can the running location make a difference. Does Eclipse do something weird here?</p> <p>Also, is there any way to not have the individual tests run once, and then all run again when it reaches the testing suite file.</p> <p>testCreateTarget(unit.targetTest) java.lang.AssertionError: Unable to create a target at unit.targetTest.testCreateTarget(TargetTest.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0</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.
    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