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

jimin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new b268838cce test: updated 3 tests in StringUtilsTest to use 
parameterized (#7295)
b268838cce is described below

commit b268838ccedb05a6bc4d0148ddf8191a2543e77b
Author: Monil <16ucs...@lnmiit.ac.in>
AuthorDate: Sun Apr 27 05:09:48 2025 -0700

    test: updated 3 tests in StringUtilsTest to use parameterized (#7295)
---
 changes/en-us/2.x.md                               | 14 +++++
 changes/zh-cn/2.x.md                               | 14 +++++
 .../apache/seata/common/util/StringUtilsTest.java  | 61 +++++++++++++++-------
 3 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index b6532ae7c9..fe20f90888 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -42,8 +42,22 @@ Add changes here for all PR submitted to the 2.x branch.
 
 ### test:
 
+- [[#7092](https://github.com/apache/incubator-seata/pull/7092)] fix the issue 
of NacosMockTest failing to run
+- [[#7098](https://github.com/apache/incubator-seata/pull/7098)] Add unit 
tests for the `seata-common` module
+- [[#7160](https://github.com/apache/incubator-seata/pull/7160)] Refactored 
tests in `LowerCaseLinkHashMapTest` to use parameterized unit testing
+- [[#7167](https://github.com/apache/incubator-seata/pull/7167)] Refactored 
tests in `DurationUtilTest` to simplify and use parameterized unit testing
+- [[#7189](https://github.com/apache/incubator-seata/pull/7189)] fix the 
runtime exception in the saga test case
+- [[#7197](https://github.com/apache/incubator-seata/pull/7197)] add some UT 
cases for config module
+- [[#7199](https://github.com/apache/incubator-seata/pull/7199)] add some UT 
cases for client processor
+- [[#7203](https://github.com/apache/incubator-seata/pull/7203)] Refactored 
tests in rm.datasource.sql.Druid and seata-sqlparser-druid module
+- [[#7221](https://github.com/apache/incubator-seata/pull/7221)] add UT for 
gRPC Encoder/Decode
+- [[#7227](https://github.com/apache/incubator-seata/pull/7227)] add mock test 
for seata-discovery-consul module
+- [[#7233][https://github.com/apache/incubator-seata/pull/7233]] add mock test 
for seata-discovery-etcd3
+- [[#7243](https://github.com/apache/incubator-seata/pull/7243)] add unit test 
for seata-discovery-eureka
+- [[#7255](https://github.com/apache/incubator-seata/pull/7255)] more unit 
tests for Discovery-Eureka
 - [[#7286](https://github.com/apache/incubator-seata/pull/7286)] Simplified 
complex test testMsgSerialize in RaftSyncMessageTest by separating it into two 
tests
 - [[#7287](https://github.com/apache/incubator-seata/pull/7287)] Refactored 
testGetErrorMsgWithValidCodeReturnsExpectedMsg to use parameterized unit testing
+- [[#7295](https://github.com/apache/incubator-seata/pull/7295)] updated 3 
tests in StringUtilsTest to use parameterized unit testing
 
 ### refactor:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index d6d6cc2b4a..4a673d7b27 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -41,8 +41,22 @@
 
 ### test:
 
+- [[#7092](https://github.com/apache/incubator-seata/pull/7092)] 
修复NacosMockTest测试方法并行导致测试结果被干扰失败的问题
+- [[#7098](https://github.com/apache/incubator-seata/pull/7098)] 增加 
`seata-common` 模块的测试用例
+- [[#7160](https://github.com/apache/incubator-seata/pull/7160)] 在 
LowerCaseLinkHashMapTest 中重构测试,以使用参数化单元测试
+- [[#7167](https://github.com/apache/incubator-seata/pull/7167)] 重构了 
DurationUtilTest 中的测试,以简化并使用参数化单元测试
+- [[#7189](https://github.com/apache/incubator-seata/pull/7189)] 修复saga测试用例运行异常
+- [[#7197](https://github.com/apache/incubator-seata/pull/7197)] 为 config 模块添加 
UT 测试用例
+- [[#7199](https://github.com/apache/incubator-seata/pull/7199)] 增加 client 
processor 单测用例
+- [[#7203](https://github.com/apache/incubator-seata/pull/7203)] 重构了 
rm.datasource.sql.Druid 和 seata-sqlparser-druid 模块中的测试
+- [[#7221](https://github.com/apache/incubator-seata/pull/7221)] 增加 gRPC 
Encoder/Decoder的测试用例
+- [[#7227](https://github.com/apache/incubator-seata/pull/7227)] 为 
seata-discovery-consul 增加mock测试
+- [[#7233][https://github.com/apache/incubator-seata/pull/7233]] 增加对 
seata-discovery-etcd3 的mock测试
+- [[#7243](https://github.com/apache/incubator-seata/pull/7243)] 增加对 
seata-discovery-eureka的单测
+- [[#7255](https://github.com/apache/incubator-seata/pull/7255)] 
补充更多seata-discovery-eureka模块的单测提高覆盖率
 - [[#7286](https://github.com/apache/incubator-seata/pull/7286)] 重构了 
RaftSyncMessageTest 中的 testMsgSerialize 测试,通过拆分为两个独立测试以简化逻辑
 - [[#7287](https://github.com/apache/incubator-seata/pull/7287)] 重构了 CodeTest 
中的 testGetErrorMsgWithValidCodeReturnsExpectedMsg 测试,以简化并使用参数化单元测试。
+- [[#7295](https://github.com/apache/incubator-seata/pull/7295)] 重构了 
StringUtilsTest 中的 3 个测试,改为使用参数化单元测试
 
 ### refactor:
 
diff --git 
a/common/src/test/java/org/apache/seata/common/util/StringUtilsTest.java 
b/common/src/test/java/org/apache/seata/common/util/StringUtilsTest.java
index 64c7a6ae81..87eebd00eb 100644
--- a/common/src/test/java/org/apache/seata/common/util/StringUtilsTest.java
+++ b/common/src/test/java/org/apache/seata/common/util/StringUtilsTest.java
@@ -33,11 +33,16 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Stream;
+
 import org.apache.seata.common.Constants;
 import org.apache.seata.common.holder.ObjectHolder;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.opentest4j.AssertionFailedError;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -62,29 +67,49 @@ public class StringUtilsTest {
     /**
      * Test is empty.
      */
-    @Test
-    public void testIsNullOrEmpty() {
+    @ParameterizedTest
+    @MethodSource("provideForIsNullOrEmpty")
+    void testIsNullOrEmpty(String input, boolean expected) {
+        assertThat(StringUtils.isNullOrEmpty(input)).isEqualTo(expected);
+    }
 
-        assertThat(StringUtils.isNullOrEmpty(null)).isTrue();
-        assertThat(StringUtils.isNullOrEmpty("abc")).isFalse();
-        assertThat(StringUtils.isNullOrEmpty("")).isTrue();
-        assertThat(StringUtils.isNullOrEmpty(" ")).isFalse();
+    static Stream<Arguments> provideForIsNullOrEmpty() {
+        return Stream.of(
+                Arguments.of(null, true),
+                Arguments.of("abc", false),
+                Arguments.of("", true),
+                Arguments.of(" ", false)
+        );
     }
 
-    @Test
-    public void testIsBlank() {
-        assertThat(StringUtils.isBlank(null)).isTrue();
-        assertThat(StringUtils.isBlank("abc")).isFalse();
-        assertThat(StringUtils.isBlank("")).isTrue();
-        assertThat(StringUtils.isBlank(" ")).isTrue();
+    @ParameterizedTest
+    @MethodSource("provideForIsBlank")
+    void testIsBlank(String input, boolean expected) {
+        assertThat(StringUtils.isBlank(input)).isEqualTo(expected);
     }
 
-    @Test
-    public void testIsNotBlank() {
-        assertThat(StringUtils.isNotBlank(null)).isFalse();
-        assertThat(StringUtils.isNotBlank("abc")).isTrue();
-        assertThat(StringUtils.isNotBlank("")).isFalse();
-        assertThat(StringUtils.isNotBlank(" ")).isFalse();
+    static Stream<Arguments> provideForIsBlank() {
+        return Stream.of(
+                Arguments.of(null, true),
+                Arguments.of("abc", false),
+                Arguments.of("", true),
+                Arguments.of(" ", true)
+        );
+    }
+
+    @ParameterizedTest
+    @MethodSource("provideForIsNotBlank")
+    void testIsNotBlank(String input, boolean expected) {
+        assertThat(StringUtils.isNotBlank(input)).isEqualTo(expected);
+    }
+
+    static Stream<Arguments> provideForIsNotBlank() {
+        return Stream.of(
+                Arguments.of(null, false),
+                Arguments.of("abc", true),
+                Arguments.of("", false),
+                Arguments.of(" ", false)
+        );
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to