szetszwo commented on code in PR #1232:
URL: https://github.com/apache/ratis/pull/1232#discussion_r1976690540


##########
ratis-common/src/test/java/org/apache/ratis/BaseTest.java:
##########
@@ -112,8 +106,7 @@ public void assertNoFailures() {
     ExitUtils.assertNotTerminated();
   }
 
-  // Retained to support junit 4 tests.
-  @Rule
+  @RegisterExtension

Review Comment:
   ```java
     @org.junit.Test
     public void testNameJunit4() throws Exception {
       System.out.println("testCaseName = " + testCaseName);
       System.out.println("testName = " + testName.getMethodName());
     }
   
     @org.junit.jupiter.api.Test
     public void testNameJunit5() throws Exception {
       System.out.println("testCaseName = " + testCaseName);
       System.out.println("testName = " + testName.getMethodName());
     }
   ```
   Try the `testNameJunit4` above, `RegisterExtension` does not work.  Both 
`testCaseName` and `testName` will be null in junit 4.  However, since this 
change (i.e. use null as the name) can pass all the tests including junit 4 
tests and we already have `testCaseName`, let's remove `testName`.
   
   ```diff
   @@ -106,9 +106,6 @@ public abstract class BaseTest {
        ExitUtils.assertNotTerminated();
      }
    
   -  @RegisterExtension
   -  public final TestName testName = new TestName();
   -
      private static final Supplier<File> ROOT_TEST_DIR = JavaUtils.memoize(
          () -> JavaUtils.callAsUnchecked(() -> {
            final File dir = new File(System.getProperty("test.build.data", 
"target/test/data"),
   @@ -131,9 +128,7 @@ public abstract class BaseTest {
      }
    
      public File getTestDir() {
   -    // This will work for both junit 4 and 5.
   -    final String name = testCaseName != null ? testCaseName : 
testName.getMethodName();
   -    return new File(getClassTestDir(), name);
   +    return new File(getClassTestDir(), testCaseName);
      }
    
      @SafeVarargs
   ```



##########
ratis-common/src/test/java/org/apache/ratis/BaseTest.java:
##########
@@ -87,8 +84,7 @@ public void setup(TestInfo testInfo) {
         + "." + (method == null? null : method.getName());
   }
 
-  // @Before annotation is retained to support junit 4 tests.
-  @Before
+  @BeforeEach

Review Comment:
   We cannot remove Before and After yet since the existing junit 4 tests need 
them.  We should remove them at last.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to