This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit dc11e1c0c9b35f6563bb6f6df35e5d45738db705
Author: Alexey Serbin <[email protected]>
AuthorDate: Fri Oct 31 17:53:42 2025 -0700

    [java] log test scenario name in TestKuduClient
    
    While trying to decipher logs from failing TestKuduClient in dist-test,
    I found it's hard to tell what exact scenario had failed.  To address
    the issue, this changelist adds the necessary information similar to
    what gtest outputs when running C++ tests.
    
    I thought it would be great to do this for all the Java tests, but I
    couldn't find a straightforward way to achieve this with JUnit4 if not
    copying over the whole TestWatcher boilerplate.  Even if that would be
    quite a ubiquitous Java-style approach, I'm not ready to do so.
    Instead, I think this boilerplate can be added on a test-by-test basis,
    when we find it's necessary: the majority of the tests aren't flaky
    as of today, and running tests with Gradle's 'test' task allows for
    per-scenario reporting already.
    
    Meanwhile, with JUnit5 the Extension concept [2] has been introduced,
    and it allows for having the necessary functionality by adding the
    @ExtendWith directive instead of copying the whole TestWatcher-related
    boilerplate.  An upgrade to JUnit6 (or newer) might be an opportunity
    to revisit this, if necessary.
    
    [1] https://junit.org/junit4/javadoc/latest/org/junit/rules/TestWatcher.html
    [2] 
https://docs.junit.org/current/api/org.junit.jupiter.api/org/junit/jupiter/api/extension/Extension.html
    
    Change-Id: I6f4d0e9bf5b590f5f0ce490838658091063e2aea
    Reviewed-on: http://gerrit.cloudera.org:8080/23616
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Abhishek Chennaka <[email protected]>
---
 .../java/org/apache/kudu/client/TestKuduClient.java    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java 
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
index 4cb829584..85bab61a5 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@@ -81,6 +81,9 @@ import io.netty.util.Timeout;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -115,6 +118,21 @@ public class TestKuduClient {
   @Rule
   public KuduTestHarness harness = new KuduTestHarness();
 
+  @Rule(order = Integer.MIN_VALUE)
+  public TestRule watcher = new TestWatcher() {
+    protected void starting(Description description) {
+      System.out.println("[ TEST: STARTING  ] " + description.getMethodName());
+    }
+
+    protected void succeeded(Description description) {
+      System.out.println("[ TEST: SUCCEEDED ] " + description.getMethodName());
+    }
+
+    protected void failed(Throwable e, Description description) {
+      System.out.println("[ TEST: FAILED    ] " + description.getMethodName());
+    }
+  };
+
   @Before
   public void setUp() {
     client = harness.getClient();

Reply via email to