Commit de84102
authored
Prune exceptions when JUnit.start is used (#5158)
Prune exceptions when JUnit.start is used
When using `JUnit.start` the `pruneStackTrace` algorithm immediately
sees the `TestClass.main` frame and assumes that this is the test
method because the test class name matches.
```
org.opentest4j.AssertionFailedError: expected: <11> but was: <12>
at [email protected]/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
at [email protected]/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
at [email protected]/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
at [email protected]/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:152)
at [email protected]/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:147)
at [email protected]/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:558)
at com.examp.project/com.example.project.HelloTest.stringLength(HelloTest.java:14)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
...
at [email protected]/org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:81)
at [email protected]/org.junit.start.JUnit.run(JUnit.java:63)
at [email protected]/org.junit.start.JUnit.run(JUnit.java:37)
at com.examp.project/com.example.project.HelloTest.main(HelloTest.java:9)
```
By checking if `org.junit.start` is involved further down the stack we
exclude this scenario. And can limit the stacktrace to a more readable.
```
org.opentest4j.AssertionFailedError: expected: <11> but was: <12>
at [email protected]/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:558)
at com.examp.project/com.example.project.HelloTest.stringLength(HelloTest.java:14)
at [email protected]/org.junit.start.JUnit.run(JUnit.java:37)
at com.examp.project/com.example.project.HelloTest.main(HelloTest.java:9)
```1 parent 94dc7be commit de84102
File tree
2 files changed
+49
-6
lines changed- junit-platform-commons/src/main/java/org/junit/platform/commons/util
- platform-tests/src/test/java/org/junit/platform/commons/util
2 files changed
+49
-6
lines changedLines changed: 24 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| |||
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
136 | | - | |
| 140 | + | |
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| |||
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| 149 | + | |
145 | 150 | | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
159 | 177 | | |
160 | 178 | | |
161 | 179 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
107 | 132 | | |
108 | 133 | | |
109 | 134 | | |
| |||
0 commit comments