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 c1d5d2463c test: Refactored testGetErrorMsgWithValidCodeReturnsExpectedMsg to use parameterized unit testing (#7287) c1d5d2463c is described below commit c1d5d2463c247a336baba7ed9223a55736ddfc1a Author: Monil <16ucs...@lnmiit.ac.in> AuthorDate: Tue Apr 22 06:24:01 2025 -0700 test: Refactored testGetErrorMsgWithValidCodeReturnsExpectedMsg to use parameterized unit testing (#7287) --- changes/en-us/2.x.md | 5 ++--- changes/zh-cn/2.x.md | 5 ++--- .../org/apache/seata/common/code/CodeTest.java | 25 +++++++++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 8be3ca74fe..7d5e2fa88f 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -40,8 +40,7 @@ Add changes here for all PR submitted to the 2.x branch. ### test: -- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] test XXX - +- [[#7287](https://github.com/apache/incubator-seata/pull/7287)] Refactored testGetErrorMsgWithValidCodeReturnsExpectedMsg to use parameterized unit testing ### refactor: @@ -58,6 +57,6 @@ Thanks to these contributors for their code commits. Please report an unintended <!-- Please make sure your Github ID is in the list below --> - [slievrly](https://github.com/slievrly) -- [GITHUB_ID](https://github.com/GITHUB_ID) +- [Monilnarang](https://github.com/Monilnarang) Also, we receive many valuable issues, questions and advices from our community. Thanks for you all. diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index ec6bfc1e75..7ecd4d6e91 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -41,8 +41,7 @@ ### test: -- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] test XXX - +- [[#7287](https://github.com/apache/incubator-seata/pull/7287)] 重构了 CodeTest 中的 testGetErrorMsgWithValidCodeReturnsExpectedMsg 测试,以简化并使用参数化单元测试。 ### refactor: @@ -59,6 +58,6 @@ <!-- 请确保您的 GitHub ID 在以下列表中 --> - [slievrly](https://github.com/slievrly) -- [GITHUB_ID](https://github.com/GITHUB_ID) +- [Monilnarang](https://github.com/Monilnarang) 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 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 66eeffcd87..20a8dac4b9 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 @@ -18,20 +18,29 @@ package org.apache.seata.common.code; import org.apache.seata.common.result.Code; 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 java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; public class CodeTest { - @Test - public void testGetErrorMsgWithValidCodeReturnsExpectedMsg() { - // Test case for SUCCESS - assertEquals("ok", Code.SUCCESS.getMsg()); - // Test case for ERROR - assertEquals("Server error", Code.ERROR.getMsg()); - // Test case for LOGIN_FAILED - assertEquals("Login failed", Code.LOGIN_FAILED.getMsg()); + static Stream<Arguments> codeMessageProvider() { + return Stream.of( + Arguments.of(Code.SUCCESS, "ok"), // Test case for SUCCESS + Arguments.of(Code.ERROR, "Server error"), // Test case for ERROR + Arguments.of(Code.LOGIN_FAILED, "Login failed") // Test case for LOGIN_FAILED + ); + } + + @ParameterizedTest + @MethodSource("codeMessageProvider") + public void testGetErrorMsgWithValidCodeReturnsExpectedMsg(Code code, String expectedMsg) { + assertEquals(expectedMsg, code.getMsg()); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org