0

I'm using XMLUnit to compare two XMLs. This works fine when i perform the test class manual as a jUnit test.

But now i want to call the tests i have from another class. I can perform the testMethod, but nothing happens

here an example for the class with the test:

public class Tests extends XMLTestCase{
    public void testForEquality() throws Exception {
        String myControlXML = "<msg><uuid>2376</uuid><uuuid>23767</uuuid></msg>";
        String myTestXML = "<msg><uuid>2376</uuid><uuuid>23767</uuuid></msg>";
        assertXMLEqual(myControlXML, myTestXML);
    }
}

here what i have tried to call it from another class:

public class testExternalCall{
    public static void main(String[] args) {
        Tests compareTest= new Tests ();
        compareTest.testForEquality();  
    }   
}

Blue

HamstersBlue
  • 115
  • 1
  • 1
  • 9
  • What is the error message ? Looks like you want to implement some common reusable test util methods. If so you could extend your common functionality into your child class using extends keyword. – Jay Mar 10 '14 at 10:17
  • There is no error message. Good idea but is in that case not possible, because i extend something else. – HamstersBlue Mar 10 '14 at 12:45

1 Answers1

1

Yes you can do that... Your test method would actually be called as a simple Java code and as there are no failures it would simple pass the test and would not print anything in your testExternalCall.java.

Add a System.out.println("Finished...");

in your Tests.java last line. This would gets printed.

Or change your code like below to some different value the test would fail and you would get the failure logs.

String myTestXML = "<msg><uuid>2376</uuid><uuuid>23767XXXXXXXX</uuuid></msg>"; 
Jay
  • 9,189
  • 12
  • 56
  • 96