Skip to content

Conversation

@shai-almog
Copy link
Collaborator

Summary

  • add an auto-registered JUnit 5 extension that captures console output during tests and fails when unexpected messages appear
  • introduce an @AllowConsoleOutput annotation so specific tests can opt in to logging when required
  • register the extension via service loader configuration so it applies to every core unit test run

Testing

  • mvn test (fails: missing dependency com.codenameone:codenameone-factory:jar:8.0-SNAPSHOT)

https://chatgpt.com/codex/tasks/task_e_68fb98e861f08331bc10960d53dfc050

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +25 to +42
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@github-actions
Copy link

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Oct 25, 2025

✅ Native Android screenshot tests passed.

@shai-almog shai-almog closed this Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant