Enhance Test Coverage in Test Suite issue solution - #52
Conversation
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic Password | 9e36464 | src/test/java/com/webapp/bankingportal/ValidationUtilTests.java | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
This reverts commit c160156.
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #29 by expanding the automated test suite around previously untested areas, and by adding a dedicated Spring Boot test configuration to run tests against an in-memory database rather than requiring a local MySQL instance.
Changes:
- Added new Spring Boot integration tests for
TransactionServiceandValidationUtil(41 tests total). - Introduced
application-test.propertiesfor test-only configuration (H2, JWT/mail/redis placeholders, logging). - Added H2 as a test dependency and updated
.gitignoreto allowapplication-test.propertiesto be committed.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/application-test.properties | Adds test-scoped Spring configuration (H2 in-memory DB + supporting properties). |
| src/test/java/com/webapp/bankingportal/ValidationUtilTests.java | Adds coverage for ValidationUtil static validations and repository-backed existence checks. |
| src/test/java/com/webapp/bankingportal/TransactionServiceTests.java | Adds coverage for transaction retrieval scenarios and bank-statement input validation. |
| pom.xml | Adds H2 dependency scoped to tests to avoid MySQL requirement during test runs. |
| .gitignore | Ensures application-test.properties is not ignored so CI/test runs have consistent config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| spring.datasource.password= | ||
|
|
||
| spring.jpa.database-platform=org.hibernate.dialect.H2Dialect | ||
| spring.jpa.generate-ddl=true |
| @Test | ||
| public void test_send_bank_statement_with_null_account_number() { | ||
| Assertions.assertThrows(IllegalArgumentException.class, () -> | ||
| transactionService.sendBankStatementByEmail(null)); | ||
| } | ||
|
|
||
| @Test | ||
| public void test_send_bank_statement_with_empty_account_number() { | ||
| Assertions.assertThrows(IllegalArgumentException.class, () -> | ||
| transactionService.sendBankStatementByEmail("")); | ||
| } | ||
|
|
||
| @Test | ||
| public void test_send_bank_statement_with_blank_account_number() { | ||
| Assertions.assertThrows(IllegalArgumentException.class, () -> | ||
| transactionService.sendBankStatementByEmail(" ")); | ||
| } |
| public void test_send_bank_statement_with_nonexistent_account_returns_silently() { | ||
| Assertions.assertDoesNotThrow(() -> |
Solution for Git Issue Enhance Test Coverage in Test Suite #29
This PR adds comprehensive unit tests for two previously untested areas of the codebase: TransactionService and ValidationUtil.
New test classes (41 new tests, all passing):
verification, descending date sort order, source account field) and sendBankStatementByEmail (null, empty, and blank account number validation)
uppercase/lowercase/digit/special char), validateUserDetailsNotEmpty (null user, missing fields), and doesAccountExist/doesEmailExist/doesPhoneNumberExist
Supporting testing infrastructure: