Skip to content

Conversation

Copy link

Copilot AI commented Nov 4, 2025

Adds comprehensive unit tests for foundational model, enum, and exception classes to improve code coverage and establish testing patterns.

Build System

  • Upgraded Gradle 6.3 → 7.6.4 for Java 17 compatibility
  • Added duplicatesStrategy = DuplicatesStrategy.INCLUDE to resolve resource conflict

Test Coverage Added (16 classes, 270+ methods)

Model & Constants

  • NodeType, CryptoType, ConstantConfig - enum and constant validation
  • PrecompiledRetCode, PrecompiledConstant - error code and limit constants with lookup logic
  • EnumNodeVersion - version parsing, comparison, and compatibility conversion
  • MerkleProofUnit, NodeVersion.ClientVersion - POJO getters/setters/equals/hashCode

Exceptions

  • Config: ConfigException
  • Transaction: TransactionBaseException, JsonException
  • Crypto: HashException, KeyPairException, SignatureException, UnsupportedCryptoTypeException, LoadKeyStoreException

All tests validate constructors, message/cause handling, equals/hashCode contracts, and edge cases (null, empty strings).

Coverage Impact

Metric          Before    After    Delta
─────────────────────────────────────────
Line            30.10%   30.66%   +0.56%
Instruction     25.26%   25.87%   +0.61%
Method          33.07%   33.90%   +0.83%
Class           37.98%   38.76%   +0.78%

Tests follow existing JUnit 4 patterns and provide regression protection for SDK core classes.

Original prompt

当前项目是使用的jacoco作为测试覆盖率组件,请在本项目基础上继续添加UT来增加覆盖率。

Conversation Summary

TITLE

Adding Unit Tests to Increase JaCoCo Code Coverage

USER INTENT

The user wants to add more unit tests (UT) to their existing project to increase code coverage as measured by JaCoCo (Java Code Coverage tool).

TASK DESCRIPTION

  • The project already has JaCoCo integrated for measuring test coverage
  • User needs to expand the existing unit test suite to improve coverage metrics
  • The task involves identifying uncovered or under-covered code paths and writing appropriate unit tests
  • Tests should target areas with low coverage to maximize the impact on overall coverage percentages

EXISTING

  • JaCoCo is already configured and integrated into the project as the code coverage component
  • There is an existing unit test suite in place (implied by the request to "continue adding" tests)
  • The project has coverage measurement infrastructure set up

PENDING

  • Identify specific classes, methods, or code blocks with low or no test coverage
  • Write additional unit tests targeting uncovered code paths
  • Ensure new tests follow existing project testing conventions and patterns
  • Verify that new tests execute successfully and increase coverage metrics
  • Generate updated JaCoCo coverage reports to validate improvements

CODE STATE

No specific files or code snippets were discussed in this initial message. The user has provided only the high-level request without sharing:

  • Current coverage percentages
  • Specific files needing coverage
  • Existing test structure
  • JaCoCo configuration details

RELEVANT CODE/DOCUMENTATION SNIPPETS

None provided in the conversation yet. Would need:

  • JaCoCo configuration (typically in pom.xml for Maven or build.gradle for Gradle)
  • Current coverage reports showing which areas need attention
  • Existing test examples to understand the project's testing patterns

OTHER NOTES

  • This appears to be the opening message of the conversation
  • More context will be needed to provide specific guidance, including:
    • What is the current coverage percentage?
    • Which modules or packages have the lowest coverage?
    • Are there any specific classes or methods that are priorities?
    • What testing framework is being used (JUnit 4, JUnit 5, TestNG, etc.)?
    • Are there any testing utilities or mocking frameworks already in use (Mockito, PowerMock, etc.)?
  • The user is likely looking for guidance on test writing strategy and/or assistance in implementing specific test cases

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 4, 2025 07:11
…fix duplicate resources handling

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests to increase JaCoCo coverage Add unit tests to increase JaCoCo coverage from 30.1% to 30.7% Nov 4, 2025
Copilot AI requested a review from kyonRay November 4, 2025 07:27
Copilot finished work on behalf of kyonRay November 4, 2025 07:27
@kyonRay kyonRay marked this pull request as ready for review November 4, 2025 07:40
@kyonRay kyonRay merged commit bb52c2d into release-3.9.0 Nov 4, 2025
2 of 3 checks passed
kyonRay added a commit that referenced this pull request Nov 13, 2025
…S#945)

* <fix>(build): update dependencies version, add UT with AI.

* Add unit tests to increase JaCoCo coverage from 30.1% to 30.7% (#1)

* Initial plan

* Initial setup: Upgrade Gradle to 7.6.4 for Java 17 compatibility and fix duplicate resources handling

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for model classes and exceptions to improve coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add more unit tests for model and enum classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for crypto exception classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Downgrade Gradle version to 6.3

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for SDK v3 client and transaction packages (#2)

* Initial plan

* Add unit tests for client and transaction packages - part 1

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add more unit tests for client protocol response and transaction dto classes

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for LogFilterRequest, model BO classes and CommonConstant

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Fix ResultCodeEnumTest to avoid mutating enum state in tests

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* <fix>(test): fixed tests path.

* Add comprehensive test coverage for uncovered utility, protocol, and codec classes (#4)

* Initial plan

* Add comprehensive tests for ByteUtils, ThreadPoolService, SystemInformation, SecureRandomUtils, and LinuxSecureRandom

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add comprehensive tests for JsonRpcRequest and TopicTools

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Address code review feedback - fix resource cleanup and remove redundant tests

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* <fix>(CI): fix windows ci version to 2025.

* <fix>(build): update publish url to central.sonatype.

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
kyonRay added a commit that referenced this pull request Nov 13, 2025
* Initial plan

* Initial setup: Upgrade Gradle to 7.6.4 for Java 17 compatibility and fix duplicate resources handling

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for model classes and exceptions to improve coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add more unit tests for model and enum classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for crypto exception classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Downgrade Gradle version to 6.3

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants