Skip to content

BazelJUnitOutputListener Logs Empty TestSuite on Test Suite Level Failure #327

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

Closed
amishra-u opened this issue Mar 10, 2025 · 0 comments · Fixed by #328
Closed

BazelJUnitOutputListener Logs Empty TestSuite on Test Suite Level Failure #327

amishra-u opened this issue Mar 10, 2025 · 0 comments · Fixed by #328

Comments

@amishra-u
Copy link
Contributor

Issue

When a test suite fails at the suite level, such as when a @BeforeClass method fails in a test class, BazelJUnitOutputListener logs an empty instead of properly capturing the failure. While Bazel logs the output for each test in the test class with the test result reflecting the test suite failure.

Steps to Reproduce:

  • Create a JUnit test class with a @BeforeClass method that fails (e.g., throws an exception).
  public static class TestSuiteError {
    @BeforeClass
    public static void setup() {
        throw new RuntimeException("test suite error");
    }

    @Test
    public void test1() {
      System.out.println("test1");
    }

    @Test
    public void test2() {
      System.out.println("test2");
    }
  }
  • Check the XML output generated by BazelJUnitOutputListener. The corresponding to this class will be empty.

Expected Behavior:

  • Each test in the test suite should be logged with same error log as parent test suite. Idenitical to Bazel XmlWriter.

Actual Behavior:

  • BazelJUnitOutputListener logs an empty .
illicitonion pushed a commit that referenced this issue Mar 22, 2025
…res (#328)

fixes: #327 

1. Updated code to propagate the test suite failure to each test case.
2. The test suite failure will be propagated to each child node, even if
the test is not executed.
3. Additionally, this change fixes the bug introduced in #300, which
incorrectly logged the test_suite as a testcase and logged incorrect
values for the "tests" attribute in the <testsuite> node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant