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

slachiewicz pushed a commit to branch fix-deprecated
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/fix-deprecated by this push:
     new f8dfe3c0c Refactor assertions for clarity and consistency in test cases
f8dfe3c0c is described below

commit f8dfe3c0c02a47c9ec9fabfb93bf5d9b95d4b8ee
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Jun 15 19:12:58 2026 +0200

    Refactor assertions for clarity and consistency in test cases
---
 .../surefire/report/SurefireReportTest.java        |  2 +-
 .../maven/surefire/api/util/RunOrderTest.java      |  2 +-
 .../surefire/api/util/TempFileManagerTest.java     |  2 +-
 .../maven/surefire/api/util/TestsToRunTest.java    | 10 +++---
 .../maven/surefire/booter/ClasspathTest.java       |  2 +-
 .../surefire/booter/SurefireReflectorTest.java     | 40 ++++++++++++----------
 .../maven/surefire/booter/SystemUtilsTest.java     |  4 +--
 7 files changed, 33 insertions(+), 29 deletions(-)

diff --git 
a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java
 
b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java
index 88edc4fc9..59e93dbcd 100644
--- 
a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java
+++ 
b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireReportTest.java
@@ -156,7 +156,7 @@ public void testBasicSurefireReportIfLinkXrefIsFalse() 
throws Exception {
         String htmlContent = FileUtils.fileRead(report);
 
         int idx = 
htmlContent.indexOf("./xref-test/com/shape/CircleTest.html#L44");
-        assertTrue(idx == -1);
+        assertEquals(-1, idx);
     }
 
     public void testBasicSurefireReportIfReportingIsNull() throws Exception {
diff --git 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderTest.java
 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderTest.java
index d4683caee..2c1a56dfe 100644
--- 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderTest.java
+++ 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderTest.java
@@ -44,7 +44,7 @@ public void testShouldReturnRunOrderForUpperCaseName() {
     }
 
     public void testShouldReturnNullForNullName() {
-        assertTrue(RunOrder.valueOfMulti(null).length == 0);
+        assertEquals(0, RunOrder.valueOfMulti(null).length);
     }
 
     public void testShouldThrowExceptionForInvalidName() {
diff --git 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TempFileManagerTest.java
 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TempFileManagerTest.java
index f4e37b666..15df6ddb4 100644
--- 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TempFileManagerTest.java
+++ 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TempFileManagerTest.java
@@ -65,7 +65,7 @@ public void testCreateTempFileAndDelete() {
         File tempFile = tfm.createTempFile(prefix, suffix);
         assertThat(tempFile).exists();
         assertThat(tempFile).isWritable();
-        assertTrue(tempFile.getParentFile().equals(tfm.getTempDir()));
+        assertEquals(tempFile.getParentFile(), tfm.getTempDir());
         assertThat(tempFile.getName()).startsWith(prefix);
         assertThat(tempFile.getName()).endsWith(suffix);
         assertThat(tempFile.getName()).contains((String) getInternalState(tfm, 
"baseName"));
diff --git 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TestsToRunTest.java
 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TestsToRunTest.java
index 07a926587..6bb82c241 100644
--- 
a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TestsToRunTest.java
+++ 
b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/TestsToRunTest.java
@@ -35,9 +35,9 @@ public void testGetTestSets() {
         TestsToRun testsToRun = new TestsToRun(classes);
         Iterator<Class<?>> it = testsToRun.iterator();
         assertTrue(it.hasNext());
-        assertEquals(it.next(), T1.class);
+        assertEquals(T1.class, it.next());
         assertTrue(it.hasNext());
-        assertEquals(it.next(), T2.class);
+        assertEquals(T2.class, it.next());
         assertFalse(it.hasNext());
     }
 
@@ -87,15 +87,15 @@ public void testTwoIterators() {
 
         Iterator<Class<?>> it1 = testsToRun.iterator();
 
-        assertEquals(it1.next(), T1.class);
+        assertEquals(T1.class, it1.next());
         assertTrue(it1.hasNext());
 
         Iterator<Class<?>> it2 = testsToRun.iterated();
 
-        assertEquals(it1.next(), T2.class);
+        assertEquals(T2.class, it1.next());
         assertFalse(it1.hasNext());
 
-        assertEquals(it2.next(), T1.class);
+        assertEquals(T1.class, it2.next());
         assertFalse(it1.hasNext());
     }
 
diff --git 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java
 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java
index 722129ad2..1d57d829c 100644
--- 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java
+++ 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ClasspathTest.java
@@ -177,7 +177,7 @@ public void testLoadInNewClassLoader() throws Exception {
         Class<?> cls = classLoader.loadClass(target.getName());
         assertNotNull(cls);
         assertEquals(cls.getName(), target.getName());
-        assertNotSame(cls, target);
+        assertNotSame(target, cls);
     }
 
     public void testDontLoadInNewClassLoader() throws 
SurefireExecutionException {
diff --git 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
index 9e92e3619..3b754693c 100644
--- 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
+++ 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -217,8 +217,8 @@ public void testArtifactInfoAware() {
         TestArtifactInfo testArtifactInfo = new TestArtifactInfo("12.3", 
"test");
         surefireReflector.setTestArtifactInfoAware(foo, testArtifactInfo);
         assertTrue(isCalled(foo));
-        assertEquals(testArtifactInfo.getClassifier(), "test");
-        assertEquals(testArtifactInfo.getVersion(), "12.3");
+        assertEquals("test", testArtifactInfo.getClassifier());
+        assertEquals("12.3", testArtifactInfo.getVersion());
     }
 
     public void testReporterFactory() {
@@ -268,16 +268,16 @@ public void testConvertIfRunResult() {
         SurefireReflector reflector =
                 new 
SurefireReflector(Thread.currentThread().getContextClassLoader());
         RunResult obj = (RunResult) reflector.convertIfRunResult(runResult);
-        assertEquals(obj.getCompletedCount(), 20);
-        assertEquals(obj.getErrors(), 1);
-        assertEquals(obj.getFailures(), 2);
-        assertEquals(obj.getSkipped(), 3);
+        assertEquals(20, obj.getCompletedCount());
+        assertEquals(1, obj.getErrors());
+        assertEquals(2, obj.getFailures());
+        assertEquals(3, obj.getSkipped());
         assertFalse(obj.isErrorFree());
         assertFalse(obj.isInternalError());
-        assertEquals(obj.getFailsafeCode(), (Integer) RunResult.FAILURE);
+        assertEquals((Integer) RunResult.FAILURE, obj.getFailsafeCode());
 
         assertNull(reflector.convertIfRunResult(null));
-        assertEquals(reflector.convertIfRunResult(""), "");
+        assertEquals("", reflector.convertIfRunResult(""));
     }
 
     public void testInstantiateProvider() {
@@ -286,7 +286,7 @@ public void testInstantiateProvider() {
         Object booterParams = getFoo();
         Object provider = 
reflector.instantiateProvider(DummyProvider.class.getName(), booterParams);
         assertNotNull(provider);
-        assertEquals(provider.getClass(), DummyProvider.class);
+        assertEquals(DummyProvider.class, provider.getClass());
     }
 
     public void testSetMainCliOptions() {
@@ -294,18 +294,22 @@ public void testSetMainCliOptions() {
                 new 
SurefireReflector(Thread.currentThread().getContextClassLoader());
         Object booterParams = getFoo();
         reflector.setMainCliOptions(booterParams, asList(SHOW_ERRORS, 
LOGGING_LEVEL_DEBUG));
-        assertEquals(((BaseProviderFactory) 
booterParams).getMainCliOptions().size(), 2);
-        assertEquals(((BaseProviderFactory) 
booterParams).getMainCliOptions().get(0), SHOW_ERRORS);
-        assertEquals(((BaseProviderFactory) 
booterParams).getMainCliOptions().get(1), LOGGING_LEVEL_DEBUG);
+        assertEquals(2, ((BaseProviderFactory) 
booterParams).getMainCliOptions().size());
+        assertEquals(
+                SHOW_ERRORS,
+                ((BaseProviderFactory) 
booterParams).getMainCliOptions().get(0));
+        assertEquals(
+                LOGGING_LEVEL_DEBUG,
+                ((BaseProviderFactory) 
booterParams).getMainCliOptions().get(1));
     }
 
     public void testSetSkipAfterFailureCount() {
         SurefireReflector reflector =
                 new 
SurefireReflector(Thread.currentThread().getContextClassLoader());
         Foo booterParams = (Foo) getFoo();
-        assertEquals(booterParams.getSkipAfterFailureCount(), 0);
+        assertEquals(0, booterParams.getSkipAfterFailureCount());
         reflector.setSkipAfterFailureCount(booterParams, 5);
-        assertEquals(booterParams.getSkipAfterFailureCount(), 5);
+        assertEquals(5, booterParams.getSkipAfterFailureCount());
     }
 
     @SuppressWarnings("checkstyle:magicnumber")
@@ -315,7 +319,7 @@ public void testSetSystemExitTimeout() {
         Foo booterParams = (Foo) getFoo();
         assertNull(booterParams.getSystemExitTimeout());
         reflector.setSystemExitTimeout(booterParams, 60);
-        assertEquals(booterParams.getSystemExitTimeout(), (Integer) 60);
+        assertEquals((Integer) 60, booterParams.getSystemExitTimeout());
     }
 
     public void testSetTestSuiteDefinitionAware() {
@@ -329,7 +333,7 @@ public void testSetTestSuiteDefinitionAware() {
         assertTrue(booterParams.getTestRequest().getSuiteXmlFiles().isEmpty());
         assertNull(booterParams.getTestRequest().getTestSourceDirectory());
         assertNull(booterParams.getTestRequest().getTestListResolver());
-        
assertEquals(booterParams.getTestRequest().getRerunFailingTestsCount(), 0);
+        assertEquals(0, 
booterParams.getTestRequest().getRerunFailingTestsCount());
     }
 
     public void testSetProviderPropertiesAware() {
@@ -339,8 +343,8 @@ public void testSetProviderPropertiesAware() {
         reflector.setProviderPropertiesAware(booterParams, 
Collections.singletonMap("k", "v"));
         assertTrue(booterParams.isCalled());
         assertNotNull(booterParams.getProviderProperties());
-        assertEquals(booterParams.getProviderProperties().size(), 1);
-        assertEquals(booterParams.getProviderProperties().get("k"), "v");
+        assertEquals(1, booterParams.getProviderProperties().size());
+        assertEquals("v", booterParams.getProviderProperties().get("k"));
     }
 
     private SurefireReflector getReflector() {
diff --git 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
index 6752ba75b..e0f3760f2 100644
--- 
a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
+++ 
b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
@@ -39,8 +39,8 @@
 import static 
org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_OPEN_BSD;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assume.assumeTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.when;
 import static org.powermock.api.mockito.PowerMockito.mockStatic;

Reply via email to