This discussion is archived
1 Reply Latest reply: Mar 29, 2007 2:40 AM by 807597 RSS

JUnit test gives ClassCastException

807597 Newbie
Currently Being Moderated
I'm trying to migrate some JUnit 3.8 tests to 4.3. At the moment my tests run fine in Eclipse, but when I try to run them from the command line they fall over with a "ClassCastException" error. This happens even when all the actual tests are ignored, e.g.:
package ac.nott.chem.lattice;

import java.util.ArrayList;

import ac.nott.chem.lattice.Helper;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class HelperTest {
     
     @Ignore
         @Test public void testFileIO() {
          ArrayList<String> lines = Helper.readFromFile("search.inp");
          assertEquals(76, lines.size());
          assertEquals("A 3 -4 0", lines.get(0));
          assertEquals("TEMP 1.5", lines.get(75));
          Helper.printToScreen(lines);
          Helper.printToFile("test.out", lines);

     }
If anyone has any suggestions as to what might be causing the problem, I'd be very grateful! I'm running the JUnit tests from the command line like so (obviously without the lines breaks, just introduced here for ease of viewing):
java -classpath /opt/junit4.3/:/opt/junit4.3/junit-4.3.jar:
/home/haydnw/workspace/JavaLatticeSearch/build/:
/home/haydnw/workspace/JavaLatticeSearch/testbuild/
junit.textui.TestRunner ac.nott.chem.lattice.HelperTest
I've read through the Javadoc for "ClassCastException" and can't see what in the test code might be the issue? This happens with all my tests, which worked fine in JUnit 3.8, and all work fine in JUnit 4.3 through Eclipse. Thanks in advance.