1 Reply Latest reply on Mar 29, 2007 9:40 AM by 807597

    JUnit test gives ClassCastException

      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 {
               @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.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:
      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.