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 ad07251662 test: Refactored testSetCodeAndMsgUpdatesValuesCorrectly to use parameterized unit testing (#7288) ad07251662 is described below commit ad072516621d87b168e3d4f3869a689f0fa85f9c Author: Monil <16ucs...@lnmiit.ac.in> AuthorDate: Sun May 11 07:16:08 2025 -0700 test: Refactored testSetCodeAndMsgUpdatesValuesCorrectly to use parameterized unit testing (#7288) --- changes/en-us/2.x.md | 1 + changes/zh-cn/2.x.md | 1 + .../java/org/apache/seata/common/code/CodeTest.java | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 85e55f0f94..45822fec2f 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -58,6 +58,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#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 +- [[#7288](https://github.com/apache/incubator-seata/pull/7288)] Refactored testSetCodeAndMsgUpdatesValuesCorrectly to use parameterized unit testing - [[#7294](https://github.com/apache/incubator-seata/pull/7294)] improved test testGetInsertParamsValue in SqlServerInsertRecognizerTest by splitting and parameterizing - [[#7295](https://github.com/apache/incubator-seata/pull/7295)] updated 3 tests in StringUtilsTest to use parameterized unit testing - [[#7205](https://github.com/apache/incubator-seata/issues/7205)] add UT for namingserver module diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index af54100470..c796d2f816 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -57,6 +57,7 @@ - [[#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 测试,以简化并使用参数化单元测试。 +- [[#7288](https://github.com/apache/incubator-seata/pull/7288)] 重构了 CodeTest 中的 testSetCodeAndMsgUpdatesValuesCorrectly 测试,以简化并使用参数化单元测试。 - [[#7294](https://github.com/apache/incubator-seata/pull/7294)] 重构了 SqlServerInsertRecognizerTest 中的 testGetInsertParamsValue 测试,通过拆分并使用参数化单元测试进行改进 - [[#7295](https://github.com/apache/incubator-seata/pull/7295)] 重构了 StringUtilsTest 中的 3 个测试,改为使用参数化单元测试 - [[#7205](https://github.com/apache/incubator-seata/issues/7205)] 为 namingserver module 添加单元测试 diff --git a/common/src/test/java/org/apache/seata/common/code/CodeTest.java b/common/src/test/java/org/apache/seata/common/code/CodeTest.java index 20a8dac4b9..592d03fd28 100644 --- a/common/src/test/java/org/apache/seata/common/code/CodeTest.java +++ b/common/src/test/java/org/apache/seata/common/code/CodeTest.java @@ -49,12 +49,18 @@ public class CodeTest { assertNull(Code.getErrorMsg("404")); } - @Test - public void testSetCodeAndMsgUpdatesValuesCorrectly() { - // Test case to check if setCode and setMsg are working as expected - Code.SUCCESS.setCode("201"); - Code.SUCCESS.setMsg("Created"); - assertEquals("201", Code.SUCCESS.getCode()); - assertEquals("Created", Code.SUCCESS.getMsg()); + static Stream<Arguments> codeSetterProvider() { + return Stream.of( + Arguments.of(Code.SUCCESS, "201", "Created") + ); + } + + @ParameterizedTest + @MethodSource("codeSetterProvider") + public void testSetCodeAndMsgUpdatesValuesCorrectly(Code code, String newCode, String newMsg) { + code.setCode(newCode); + code.setMsg(newMsg); + assertEquals(newCode, code.getCode()); + assertEquals(newMsg, code.getMsg()); } } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org