-
Notifications
You must be signed in to change notification settings - Fork 428
Enforce console output checks in core unit tests #4073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public void beforeEach(ExtensionContext context) { | ||
| CapturedStreams captured = new CapturedStreams(System.out, System.err); | ||
| getStore(context).put(context.getUniqueId(), captured); | ||
|
|
||
| System.setOut(captured.createInterceptingStream(captured.originalOut, captured.capturedOut)); | ||
| System.setErr(captured.createInterceptingStream(captured.originalErr, captured.capturedErr)); | ||
| } | ||
|
|
||
| @Override | ||
| public void afterEach(ExtensionContext context) { | ||
| CapturedStreams captured = | ||
| getStore(context).remove(context.getUniqueId(), CapturedStreams.class); | ||
| if (captured == null) { | ||
| return; | ||
| } | ||
|
|
||
| System.setOut(captured.originalOut); | ||
| System.setErr(captured.originalErr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard console stream swapping against parallel tests
The extension unconditionally replaces the JVM‑wide System.out and System.err for each test run and restores them afterwards. That works when tests execute sequentially, but JUnit 5 allows concurrent execution and surefire can enable it via junit.jupiter.execution.parallel.enabled=true. With parallel tests, one invocation of beforeEach will overwrite the streams that another test is already using, and whichever afterEach runs last will restore the wrong streams. This leads to nondeterministic failures and, worse, some tests’ console output escaping the check entirely. Consider synchronizing access or opting out of parallel execution to ensure per‑test isolation.
Useful? React with 👍 / 👎.
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
|
✅ Native Android screenshot tests passed. |
Summary
@AllowConsoleOutputannotation so specific tests can opt in to logging when requiredTesting
https://chatgpt.com/codex/tasks/task_e_68fb98e861f08331bc10960d53dfc050