File tree 4 files changed +24
-6
lines changed
main/java/io/codeclou/java/junit/xml/merger
java/io/codeclou/java/junit/xml/merger
4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 4
4
<modelVersion >4.0.0</modelVersion >
5
5
<groupId >io.codeclou</groupId >
6
6
<artifactId >java-junit-xml-merger</artifactId >
7
- <version >1.0.0 </version >
7
+ <version >1.0.1 </version >
8
8
<organization >
9
9
<name >codeclou.io</name >
10
10
<url >http://codeclou.io/</url >
Original file line number Diff line number Diff line change 27
27
import io .codeclou .java .junit .xml .merger .model .TestSuites ;
28
28
import org .apache .commons .cli .*;
29
29
import org .w3c .dom .Document ;
30
+ import org .w3c .dom .NamedNodeMap ;
30
31
import org .w3c .dom .Node ;
31
32
import org .xml .sax .SAXException ;
32
33
@@ -59,12 +60,13 @@ protected TestSuite parseTestSuite(File filename) throws ParserConfigurationExce
59
60
60
61
public TestSuite transform (Node testSuite ) {
61
62
TestSuite t = new TestSuite ();
62
- t .setTests (Long .valueOf (testSuite .getAttributes ().getNamedItem ("tests" ).getNodeValue ()));
63
- t .setErrors (Long .valueOf (testSuite .getAttributes ().getNamedItem ("errors" ).getNodeValue ()));
64
- t .setFailures (Long .valueOf (testSuite .getAttributes ().getNamedItem ("failures" ).getNodeValue ()));
65
- t .setSkipped (Long .valueOf (testSuite .getAttributes ().getNamedItem ("skipped" ).getNodeValue ()));
63
+ NamedNodeMap attrs = testSuite .getAttributes ();
64
+ t .setTests (attrs .getNamedItem ("tests" ) != null ? Long .valueOf (attrs .getNamedItem ("tests" ).getNodeValue ()) : 0L );
65
+ t .setErrors (attrs .getNamedItem ("errors" ) != null ? Long .valueOf (testSuite .getAttributes ().getNamedItem ("errors" ).getNodeValue ()) : 0L );
66
+ t .setFailures (attrs .getNamedItem ("failures" ) != null ? Long .valueOf (testSuite .getAttributes ().getNamedItem ("failures" ).getNodeValue ()) : 0L );
67
+ t .setSkipped (attrs .getNamedItem ("skipped" ) != null ? Long .valueOf (testSuite .getAttributes ().getNamedItem ("skipped" ).getNodeValue ()) : 0L );
66
68
t .setName (testSuite .getAttributes ().getNamedItem ("name" ).getNodeValue ());
67
- t .setTime (Double .valueOf (testSuite .getAttributes ().getNamedItem ("time" ).getNodeValue ()));
69
+ t .setTime (attrs . getNamedItem ( "time" ) != null ? Double .valueOf (testSuite .getAttributes ().getNamedItem ("time" ).getNodeValue ()) : 0.0 );
68
70
t .setXml (testSuite );
69
71
return t ;
70
72
}
Original file line number Diff line number Diff line change @@ -52,6 +52,19 @@ public void testParse() throws Exception {
52
52
assertNotNull (t .getXml ());
53
53
}
54
54
55
+ @ Test
56
+ public void testParseNotSoWellFormed () throws Exception {
57
+ JunitXmlParser parser = new JunitXmlParser ();
58
+ TestSuite t = parser .parseTestSuite (getTestFile ("my-not-so-well-formed-component-test.xml" ));
59
+ assertEquals (Long .valueOf (0L ), t .getErrors ());
60
+ assertEquals (Long .valueOf (0L ), t .getFailures ());
61
+ assertEquals (Long .valueOf (0L ), t .getSkipped ());
62
+ assertEquals (Long .valueOf (0L ), t .getTests ());
63
+ assertTrue (t .getTime () >= 0.0 );
64
+ assertEquals ("i.am.empty.but.sometimes.that.happens" , t .getName ());
65
+ assertNotNull (t .getXml ());
66
+ }
67
+
55
68
@ Test
56
69
public void testRunInvalidInput1 () throws Exception {
57
70
String [] args = {};
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <testsuite name =" i.am.empty.but.sometimes.that.happens" >
3
+ </testsuite >
You can’t perform that action at this time.
0 commit comments