I am working on a Junit test where the output of a method is a String in XML format.I am not sure why the string comparison is failing
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
"<RATE>1.0</RATE>", XMLUtil.formatXML(TEST_XML));
Actaul response from the method :
<?xml version="1.0" encoding="ISO-8859-1"?>
<RATE>1.0</RATE>
Error :
junit.framework.ComparisonFailure: expected:<...oding="ISO-8859-1"?>[
<RATE>1.0</RATE>]> but was:<...oding="ISO-8859-1"?>[
<RATE>1.0</RATE>
]>
]
EDIT Even adding new line in the end doesnt help:
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
"<RATE>1.0</RATE>\n", XMLUtil.formatXML(TEST_XML));
junit.framework.ComparisonFailure: expected:<...oding="ISO-8859-1"?>[
<RATE>1.0</RATE>]
> but was:<...oding="ISO-8859-1"?>[
<RATE>1.0</RATE>
]
>