Copilot commented on code in PR #8625:
URL: https://github.com/apache/hbase/pull/8625#discussion_r3948602640


##########
hbase-website/app/pages/_docs/docs/_mdx/(multi-page)/building-and-developing/tests.mdx:
##########
@@ -369,42 +382,39 @@ This will allow to share the cluster later.
 
 ### Tests Skeleton Code
 
-Here is a test skeleton code with Categorization and a Category-based timeout 
rule to copy and paste and use as basis for test contribution.
+Here is a test skeleton code with sizing tags to copy and paste and use as 
basis for test contribution.
 
 ```java
 /**
- * Describe what this testcase tests. Talk about resources initialized in 
@BeforeClass (before
+ * Describe what this testcase tests. Talk about resources initialized in 
@BeforeAll (before
  * any test is run) and before each test is run, etc.
  */
-// Specify the category as explained in Unit Tests section.
-@Category(SmallTests.class)
+// Specify the sizing tag as explained in the Unit Tests section. Most tests 
also carry a
+// functional tag such as RegionServerTests, ClientTests, MasterTests, etc.
+@Tag(RegionServerTests.TAG)
+@Tag(SmallTests.TAG)
 public class TestExample {
   // Replace the TestExample.class in the below with the name of your test 
fixture class.
-  private static final Log LOG = LogFactory.getLog(TestExample.class);
-
-  // Handy test rule that allows you subsequently get the name of the current 
method. See
-  // down in 'testExampleFoo()' where we use it to log current test's name.
-  @Rule public TestName testName = new TestName();
+  private static final Logger LOG = LoggerFactory.getLogger(TestExample.class);
 
-  // The below rule does two things. It decides the timeout based on the 
category
-  // (small/medium/large) of the testcase. This @Rule requires that the full 
testcase runs
-  // within this timeout irrespective of individual test methods' times. The 
second
-  // feature is we'll dump in the log when the test is done a count of threads 
still
-  // running.
-  @Rule public static TestRule timeout = CategoryBasedTimeout.builder().
-    withTimeout(this.getClass()).withLookingForStuckThread(true).build();
+  // There is no per-class timeout rule to declare. HBaseJupiterExtension is 
auto-registered
+  // and, based on the sizing tag above, enforces the whole-class timeout, 
dumps a thread
+  // stack if the class times out, and runs the resource checker.
+  //
+  // To get the name of the current test method, inject a JUnit 5 TestInfo 
into your setUp or
+  // test methods. See down in 'testExampleFoo()' where we use it to log the 
current test's name.
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   }
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   }
 
   @Test
-  public void testExampleFoo() {
-    LOG.info("Running test " + testName.getMethodName());
+  public void testExampleFoo(TestInfo testInfo) {
+    LOG.info("Running test " + testInfo.getTestMethod().get().getName());

Review Comment:
   This example can throw `NoSuchElementException` because 
`TestInfo.getTestMethod()` is optional (e.g., certain dynamic/container 
scenarios). Safer for copy/paste docs: log `testInfo.getDisplayName()` or use 
`getTestMethod().map(...).orElse(...)`.



##########
dev-support/hbasetests.sh:
##########
@@ -210,13 +210,13 @@ do
     isLarge=0
 
     # determine the category of the test by greping into the source code
-    isMedium=`grep "@Category" $testFile | grep "MediumTests.class" | wc -l`
+    isMedium=`grep -F "Tag(MediumTests.TAG)" $testFile | wc -l`
     if (test $isMedium -eq 0)
     then
-      isLarge=`grep "@Category" $testFile | grep "LargeTests.class" | wc -l`
+      isLarge=`grep -F "Tag(LargeTests.TAG)" $testFile | wc -l`
       if (test $isLarge -eq 0)
       then
-        isSmall=`grep "@Category" $testFile | grep "SmallTests.class" | wc -l`
+        isSmall=`grep -F "Tag(SmallTests.TAG)" $testFile | wc -l`

Review Comment:
   These updated lines continue to use legacy backticks and leave `$testFile` 
unquoted, which can break on unexpected characters/whitespace and makes the 
script harder to maintain. Prefer `$(...)` command substitution and quote 
`$testFile` (and consider collapsing to a single grep without piping to `wc 
-l`, since the exit code can be used for 0/1 presence checks).



-- 
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