You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "maple525866 (via GitHub)" <gi...@apache.org> on 2025/11/11 14:27:41 UTC

[PR] test: add UT for XA module [incubator-seata]

maple525866 opened a new pull request, #7776:
URL: https://github.com/apache/incubator-seata/pull/7776

   <!--
       Licensed to the Apache Software Foundation (ASF) under one or more
       contributor license agreements.  See the NOTICE file distributed with
       this work for additional information regarding copyright ownership.
       The ASF licenses this file to You under the Apache License, Version 2.0
       (the "License"); you may not use this file except in compliance with
       the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
       
       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.
   -->
   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have read the [CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md) guidelines.
   - [ ] I have registered the PR [changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
   
   ### Ⅰ. Describe what this PR did
   add UT for XA module
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "maple525866 (via GitHub)" <gi...@apache.org>.
maple525866 commented on PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#issuecomment-3525018140

   > Based on the Codecov report, it seems that ConnectionProxyXA (49%) and PreparedStatementProxyXA (38.74%) have relatively low coverage. It might be helpful to add some targeted test cases for these two classes to achieve a better overall result.
   
   Okay, I'll make further revisions later.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "maple525866 (via GitHub)" <gi...@apache.org>.
maple525866 merged PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "lokidundun (via GitHub)" <gi...@apache.org>.
lokidundun commented on PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#issuecomment-3561886708

   > LGTM.
   
   There are something wrong with some tests, when this was merged, all of the ci can not be passed


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "WangzJi (via GitHub)" <gi...@apache.org>.
WangzJi commented on code in PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#discussion_r2541802009


##########
rm-datasource/src/test/java/org/apache/seata/rm/datasource/xa/ExecuteTemplateXATest.java:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.xa;
+
+import org.apache.seata.rm.datasource.exec.StatementCallback;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Tests for ExecuteTemplateXA
+ *
+ */
+public class ExecuteTemplateXATest {
+
+    @Test
+    public void testExecuteSuccessWithAutoCommitTrue() throws SQLException {
+        // Mock connection proxy
+        AbstractConnectionProxyXA mockConnectionProxyXA = Mockito.mock(AbstractConnectionProxyXA.class);

Review Comment:
   Nice work on the tests! Would it be possible to extract the repeated mock setup to `@BeforeEach`? The same mocks are created in most test methods. Thanks!
   



-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "WangzJi (via GitHub)" <gi...@apache.org>.
WangzJi commented on PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#issuecomment-3524979349

   Based on the Codecov report, it seems that ConnectionProxyXA (49%) and PreparedStatementProxyXA (38.74%) have relatively low coverage.
   It might be helpful to add some targeted test cases for these two classes to achieve a better overall result.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "maple525866 (via GitHub)" <gi...@apache.org>.
maple525866 commented on code in PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#discussion_r2542011239


##########
rm-datasource/src/test/java/org/apache/seata/rm/datasource/xa/ExecuteTemplateXATest.java:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm.datasource.xa;
+
+import org.apache.seata.rm.datasource.exec.StatementCallback;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Tests for ExecuteTemplateXA
+ *
+ */
+public class ExecuteTemplateXATest {
+
+    @Test
+    public void testExecuteSuccessWithAutoCommitTrue() throws SQLException {
+        // Mock connection proxy
+        AbstractConnectionProxyXA mockConnectionProxyXA = Mockito.mock(AbstractConnectionProxyXA.class);

Review Comment:
   done



-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] test: add UT for XA module [incubator-seata]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7776:
URL: https://github.com/apache/incubator-seata/pull/7776#issuecomment-3517268776

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/7776?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 69.63%. Comparing base ([`ca68871`](https://app.codecov.io/gh/apache/incubator-seata/commit/ca68871b318f8d5b9715b59d96e8adc8921ef70c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7a9db0b`](https://app.codecov.io/gh/apache/incubator-seata/commit/7a9db0bafce8a046ec7048b797dc96617ba12c19?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #7776      +/-   ##
   ============================================
   + Coverage     69.03%   69.63%   +0.59%     
     Complexity      994      994              
   ============================================
     Files          1322     1322              
     Lines         50167    50167              
     Branches       5932     5932              
   ============================================
   + Hits          34635    34934     +299     
   + Misses        12590    12292     -298     
   + Partials       2942     2941       -1     
   ```
   [see 14 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/7776/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/7776/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/7776?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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