Skip to content

Commit 620096f

Browse files
Carlos Gomezfacebook-github-bot
authored andcommitted
fix sender initialization so only one is created
Summary: Sender was being initialized once per class, leading to only the final class's tests reporting results. This moves it to the right spot. Reviewed By: IanChilds Differential Revision: D75086195 fbshipit-source-id: 5fef6e49bb85edbb992cd1eca456d765964050a4
1 parent 71367a3 commit 620096f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

prelude/toolchains/android/src/com/facebook/buck/testrunner/JUnitRunner.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public void run() throws Throwable {
9191
stdErrLogLevel = Level.parse(unparsedStdErrLogLevel);
9292
}
9393

94+
// TPX sets the env var that enables the Standard Output format
95+
Optional<TestResultsOutputSender> testResultsOutputSender =
96+
TestResultsOutputSender.fromDefaultEnvName();
97+
9498
for (String className : testClassNames) {
9599
Class<?> testClass = Class.forName(className);
96100
Class<?>[] testClasses;
@@ -109,11 +113,6 @@ public void run() throws Throwable {
109113
request = request.filterWith(filter);
110114
jUnitCore.addListener(new TestListener(results, stdOutLogLevel, stdErrLogLevel));
111115

112-
// testResultsOutputSender will only be present if the environment variable is set to use
113-
// TPX Standard Output. In that case, we want to add the listener so the test results JSON
114-
// file is written.
115-
Optional<TestResultsOutputSender> testResultsOutputSender =
116-
TestResultsOutputSender.fromDefaultEnvName();
117116
if (testResultsOutputSender.isPresent()) {
118117
JUnitTpxStandardOutputListener tpxListener =
119118
new JUnitTpxStandardOutputListener(testResultsOutputSender.get());

0 commit comments

Comments
 (0)