1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
package io.codeclou.java.junit.xml.merger; |
25 |
|
|
26 |
|
import io.codeclou.java.junit.xml.merger.model.TestSuite; |
27 |
|
import org.junit.Test; |
28 |
|
import org.mockito.internal.util.reflection.Whitebox; |
29 |
|
|
30 |
|
import java.io.File; |
31 |
|
|
32 |
|
import static junit.framework.TestCase.assertFalse; |
33 |
|
import static org.junit.Assert.*; |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (56) |
Complexity: 8 |
Complexity Density: 0,17 |
|
35 |
|
public class JunitXmlParserTest { |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
37 |
1 |
private File getTestFile(String filename) {... |
38 |
1 |
ClassLoader classLoader = getClass().getClassLoader(); |
39 |
1 |
return new File(classLoader.getResource(filename).getFile()); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void testParse() throws Exception { |
44 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
45 |
1 |
TestSuite t = parser.parseTestSuite(getTestFile("sort-model-test.xml")); |
46 |
1 |
assertEquals(Long.valueOf(0L), t.getErrors()); |
47 |
1 |
assertEquals(Long.valueOf(0L), t.getFailures()); |
48 |
1 |
assertEquals(Long.valueOf(0L), t.getSkipped()); |
49 |
1 |
assertEquals(Long.valueOf(3L), t.getTests()); |
50 |
1 |
assertTrue(t.getTime() > 0.028); |
51 |
1 |
assertEquals("ut.io.codeclou.customfield.editor.model.rest.SortModelTest", t.getName()); |
52 |
1 |
assertNotNull(t.getXml()); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void testRunInvalidInput1() throws Exception { |
57 |
1 |
String[] args = {}; |
58 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
59 |
1 |
parser.run(args); |
60 |
1 |
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors"); |
61 |
1 |
assertTrue(hasCmdLineParameterErrors); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1PASS
|
|
64 |
1 |
@Test... |
65 |
|
public void testRunInvalidInput2() throws Exception { |
66 |
1 |
String[] args = {"-i=foo"}; |
67 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
68 |
1 |
parser.run(args); |
69 |
1 |
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors"); |
70 |
1 |
assertTrue(hasCmdLineParameterErrors); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1PASS
|
|
73 |
1 |
@Test... |
74 |
|
public void testRunInvalidInput3() throws Exception { |
75 |
1 |
String[] args = {"-i=foo", "-o=bar.xml"}; |
76 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
77 |
1 |
parser.run(args); |
78 |
1 |
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors"); |
79 |
1 |
assertTrue(hasCmdLineParameterErrors); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1PASS
|
|
82 |
1 |
@Test... |
83 |
|
public void testRunValidInputWithInvalidFolders() throws Exception { |
84 |
1 |
String[] args = {"-i=foo", "-o=?x/bar.xml", "-s=foo"}; |
85 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
86 |
1 |
parser.run(args); |
87 |
1 |
Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(parser, "hasFileNotFoundErrors"); |
88 |
1 |
assertTrue(hasFileNotFoundErrors); |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1PASS
|
|
91 |
1 |
@Test... |
92 |
|
public void testRunValidInputWithValidFolders() throws Exception { |
93 |
1 |
String[] args = {"-i=src/test/resources/", "-o=output.xml", "-s=foo bar"}; |
94 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
95 |
1 |
parser.run(args); |
96 |
1 |
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors"); |
97 |
1 |
assertFalse(hasCmdLineParameterErrors); |
98 |
1 |
Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(parser, "hasFileNotFoundErrors"); |
99 |
1 |
assertFalse(hasFileNotFoundErrors); |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1PASS
|
|
102 |
1 |
@Test... |
103 |
|
public void testRunValidInputWithEmptyInputFolder() throws Exception { |
104 |
1 |
File emptyDir = new File("src/test/resources/empty/"); |
105 |
1 |
emptyDir.mkdir(); |
106 |
1 |
String[] args = {"-i=src/test/resources/empty/", "-o=output.xml", "-s=foo bar"}; |
107 |
1 |
JunitXmlParser parser = new JunitXmlParser(); |
108 |
1 |
parser.run(args); |
109 |
1 |
Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(parser, "hasCmdLineParameterErrors"); |
110 |
1 |
assertFalse(hasCmdLineParameterErrors); |
111 |
1 |
Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(parser, "hasFileNotFoundErrors"); |
112 |
1 |
assertFalse(hasFileNotFoundErrors); |
113 |
1 |
emptyDir.delete(); |
114 |
|
} |
115 |
|
} |