1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.devacfr.testing.jupiter; |
20 |
|
|
21 |
|
import javax.annotation.Nonnull; |
22 |
|
import javax.annotation.Nullable; |
23 |
|
|
24 |
|
import java.nio.file.Path; |
25 |
|
import java.nio.file.Paths; |
26 |
|
import java.util.function.Function; |
27 |
|
|
28 |
|
import com.google.common.io.ByteSource; |
29 |
|
import com.google.common.io.Resources; |
30 |
|
import org.devacfr.testing.util.Approvals; |
31 |
|
import org.junit.jupiter.api.Assertions; |
32 |
|
import org.junit.jupiter.api.BeforeEach; |
33 |
|
import org.junit.jupiter.api.TestInfo; |
34 |
|
|
|
|
| 55% |
Uncovered Elements: 18 (40) |
Complexity: 19 |
Complexity Density: 0,95 |
|
35 |
|
public class TestCase extends Assertions { |
36 |
|
|
37 |
|
private TestInfo testInfo; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
66 |
@BeforeEach... |
40 |
|
public final void beforeEachMethod(final TestInfo testInfo) { |
41 |
66 |
this.testInfo = testInfo; |
42 |
|
} |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
0 |
public String getName() {... |
45 |
0 |
return this.getClass().getSimpleName(); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@return |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
42 |
@Nonnull... |
54 |
|
public final Path getPackagePath() { |
55 |
42 |
return Paths.get(getPackagePath(this.getClass())); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
6 |
public ByteSource getResource(final String filename) {... |
59 |
6 |
return Resources.asByteSource(Resources.getResource(getPackagePath().resolve(filename).toString())); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
@param |
66 |
|
|
67 |
|
@return |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
42 |
@Nonnull... |
70 |
|
public static final String getPackagePath(@Nonnull final Class<?> testClass) { |
71 |
42 |
return testClass.getPackage().getName().replace('.', '/'); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
7 |
public String getActualResource() {... |
75 |
7 |
return Approvals.getActualResource(getPackagePath(), this.getClass(), getMethodName(), null); |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
0 |
public String getExpectedResource() {... |
79 |
0 |
return Approvals.getExpectedResource(getPackagePath(), this.getClass(), getMethodName(), null, null); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
2 |
public String getActualResource(final String extension) {... |
83 |
2 |
return Approvals.getActualResource(getPackagePath(), this.getClass(), getMethodName(), extension); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
1 |
public String getExpectedResource(final String extension) {... |
87 |
1 |
return Approvals.getExpectedResource(getPackagePath(), this.getClass(), getMethodName(), extension, null); |
88 |
|
} |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0 |
public String getExpectedResource(final String extension, final Function<String, String> transformer) {... |
91 |
0 |
return Approvals |
92 |
|
.getExpectedResource(getPackagePath(), this.getClass(), getMethodName(), extension, transformer); |
93 |
|
} |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
0 |
public void verify() {... |
96 |
0 |
Approvals.verify(getPackagePath(), this.getClass(), getMethodName(), (Function<String, String>) null, null); |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
@param |
101 |
|
|
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
public void verify(final String extension) {... |
104 |
0 |
Approvals |
105 |
|
.verify(getPackagePath(), this.getClass(), getMethodName(), (Function<String, String>) null, extension); |
106 |
|
} |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
0 |
public void verify(final Path actualFile, final Path expectedFile) {... |
109 |
0 |
Approvals.verify(actualFile, expectedFile); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
1 |
public void verify(final Function<String, String> transform) {... |
113 |
1 |
Approvals.verify(getPackagePath(), this.getClass(), getMethodName(), transform, null); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
@param |
118 |
|
@param |
119 |
|
|
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
19 |
public void verify(final Function<String, String> transform, @Nullable final String extension) {... |
122 |
19 |
Approvals.verify(getPackagePath(), this.getClass(), getMethodName(), transform, extension); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
@param |
127 |
|
|
128 |
|
@param |
129 |
|
|
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
public void verify(@Nullable final String actual, @Nullable final String extension) {... |
132 |
0 |
Approvals.verify(getPackagePath(), this.getClass(), getMethodName(), actual, extension); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
@param |
137 |
|
|
138 |
|
@param |
139 |
|
|
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0 |
public void verify(@Nonnull final Path actualFile, @Nullable final String extension) {... |
142 |
0 |
Approvals.verify(getPackagePath(), this.getClass(), getMethodName(), actualFile, extension); |
143 |
|
} |
144 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
145 |
30 |
private String getMethodName() {... |
146 |
30 |
if (testInfo == null) { |
147 |
0 |
return null; |
148 |
|
} |
149 |
30 |
return this.testInfo.getTestMethod().get().getName(); |
150 |
|
} |
151 |
|
} |