Skip to content

Commit 21bb1ca

Browse files
authored
Merge pull request #31 from Addepar/ztai/failure-count
JUnit5: fix failure count
2 parents 9a2dc3f + acf6b3d commit 21bb1ca

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

src/com/facebook/buck/testrunner/JUnitRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public void run() throws Throwable {
9696
requestBuilder = requestBuilder.selectors(selectClass(testClass));
9797
} else {
9898
for (TestSelector selector : testSelectorList.getSelectors()) {
99-
if (selector.matchesClassName(testClass.getSimpleName())) {
99+
if (selector.matchesClassName(testClass.getSimpleName()) ||
100+
selector.matchesClassName(testClass.getCanonicalName())) {
100101
if (selector.isMatchAnyMethod()) {
101102
requestBuilder = requestBuilder.selectors(selectClass(testClass));
102103
} else {

src/com/facebook/buck/testrunner/Junit5TestListener.java

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,6 @@ public void testPlanExecutionStarted(TestPlan testPlan) {
5252
listener.testPlanExecutionStarted(testPlan);
5353
}
5454

55-
// compare to Junit4TestListener.testRunFinished
56-
@Override
57-
public void testPlanExecutionFinished(TestPlan testPlan) {
58-
// testStarted was called for latest test, but not the testFinished
59-
// report all failures as unbounded
60-
for (TestExecutionSummary.Failure failure : listener.getSummary().getFailures()) {
61-
long runtime = System.currentTimeMillis() - this.testPlanStartTime;
62-
String className = testClass.getCanonicalName();
63-
String methodName = testIdentifier.getDisplayName().replace("()", "");
64-
results.add(
65-
new TestResult(
66-
className,
67-
methodName,
68-
runtime,
69-
ResultType.FAILURE,
70-
failure.getException(),
71-
null,
72-
null));
73-
}
74-
}
75-
7655
// compare to Junit4TestListener.testIgnored
7756
@Override
7857
public void executionSkipped(TestIdentifier testIdentifier, String reason) {
@@ -150,16 +129,14 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
150129
stdErrStream.flush();
151130

152131
TestExecutionSummary summary = listener.getSummary();
153-
long numFailures = summary.getTestsFailedCount();
154-
155-
TestExecutionSummary.Failure failure;
156-
ResultType type;
157-
if (numFailures == 0) {
158-
failure = null;
159-
type = ResultType.SUCCESS;
160-
} else {
161-
failure = summary.getFailures().get(0);
162-
type = ResultType.FAILURE;
132+
TestExecutionSummary.Failure failure = null;
133+
ResultType type = ResultType.SUCCESS;
134+
for(TestExecutionSummary.Failure f : summary.getFailures()) {
135+
if(f.getTestIdentifier().equals(testIdentifier)) {
136+
failure = f;
137+
type = ResultType.FAILURE;
138+
break;
139+
}
163140
}
164141

165142
StringBuilder stdOut = new StringBuilder();

0 commit comments

Comments
 (0)