Menu

Issue with installing

Help
RB
2013-10-04
2013-10-10
  • RB

    RB - 2013-10-04

    Am receiving this issue when running javac -classpath lib/xmlunit-1.5.jar xmltest2.java

    3: error: cannot access TestCase

    Tried installed libxmlunit-java (v1.3) in Ubuntu but it still couldn't find the library. I'm using the import command:

    package org.custommonkey.xmlunit;
    import org.cutommonkey.xmlunit.*;

    and I get:

    2: error: package org.cutommonkey.xmlunit does not exist

    I'm sure this is a quick fix but I cannot seem to figure this out. How do I incorporate xmlunit into my java file?

    RB

     
  • Stefan Bodewig

    Stefan Bodewig - 2013-10-04

    In the first case you also need JUnit in yous classpath. XMLUnit 1.x is an extnesion of JUNit but neither replace nor bundles it.

    In your second case you've misspelt custommonkey (you have skipped the "s").

     

    Last edit: Stefan Bodewig 2013-10-04
  • RB

    RB - 2013-10-07

    Thanks that helped a little. I already had junit installed but I suppose I needed it in my class path so I added it using the flags -cp before I compiled it but it seems like the compile failed.

    $ javac -cp "lib/junit.jar" MyXMLTestCase.java
    Note: MyXMLTestCase.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    $ javac -cp "lib/junit.jar" MyXMLTestCase.java -Xlint:deprecation
    MyXMLTestCase.java:139: warning: [deprecation] getControlParser() in XMLUnit has been deprecated
    Document myExpectedOutputXML = XMLUnit.buildDocument(XMLUnit.getControlParser(), new FileReader("..."));
    ^
    MyXMLTestCase.java:149: warning: [deprecation] toURL() in File has been deprecated
    String myDTDUrl = new File("...").toURL().toExternalForm();
    ^
    MyXMLTestCase.java:175: warning: [deprecation] getTestParser() in XMLUnit has been deprecated
    TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder = new TolerantSaxDocumentBuilder(XMLUnit.getTestParser());
    ^
    3 warnings

    I also tried compiling a simpler file but same issues. I have junit.jar and xmlunit.jar inside my lib directory. I also tried adding a ";lib/xmlunit.jar" and it wouldn't recognize the TestCase framework...

    javac -cp "lib/junit.jar;lib/xmlunit.jar" MyXMLTestCase
    java -cp ".:lib/junit.jar;lib/xmlunit.jar" MyXMLTestCase

    I'm sort of a newbie when it comes to this. Would you please explain the steps to get this to work?

    Thanks again,

     
  • Stefan Bodewig

    Stefan Bodewig - 2013-10-10

    You don't run your tests directly via Java, you need a testrunner for JUnit tests like the console or GUI runners shipping with JUnit or the JUnit support provided by your build-tool or IDE of choice.

     

Log in to post a comment.