Sunday, April 19, 2026

Copilot - improve test coverage

 

 

 Git

 

 

Implemented.

Coverage analysis (current repo state)

  • The codebase had effectively no automated tests (@Test was not present).
  • Major untested areas included:
    • rs-api REST/resource flow and model classes
    • Most Java EE modules (dave-basic-webapp-ejb-project, etc.) also have no tests, and some are not buildable in this environment due missing Oracle artifacts.

What I changed

In sample-javaee/14.1.1/dave-basic-project/rs-api:

  • Added test dependency:
    • junit:junit:4.13.2 (test scope) in:
      • /home/runner/work/weblogic/weblogic/sample-javaee/14.1.1/dave-basic-project/rs-api/pom.xml
  • Added comprehensive unit tests:
    • /home/runner/work/weblogic/weblogic/sample-javaee/14.1.1/dave-basic-project/rs-api/src/test/java/com/dave/service/PersonTest.java
    • /home/runner/work/weblogic/weblogic/sample-javaee/14.1.1/dave-basic-project/rs-api/src/test/java/com/dave/service/PersonSessionBeanTest.java
    • /home/runner/work/weblogic/weblogic/sample-javaee/14.1.1/dave-basic-project/rs-api/src/test/java/com/dave/service/MyResourceTest.java
    • /home/runner/work/weblogic/weblogic/sample-javaee/14.1.1/dave-basic-project/rs-api/src/test/java/com/dave/service/MyApplicationTest.java
  • Fixed edge-case behavior found during testing:
    • MyResource#getPerson now handles negative IDs safely (id >= 0 check).

Validation

  • Ran:
    • mvn --no-transfer-progress test in rs-api
  • Result:
    • BUILD SUCCESS
    • 10 tests run, 0 failures, 0 errors

Review/security validation

  • Code review: clean after fixes.
  • CodeQL scan: timed out in the validation tool (no actionable alert returned before timeout).

 

No comments:

Post a Comment