Add @api tag and dedicated Cucumber runner; implement Mock API steps and DB support#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff57d3d854
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @Before("@setup") | ||
| public void cleanDb() { | ||
| mockApiServer.stop(); |
There was a problem hiding this comment.
Stop MockApiServer in an @after hook
DBCleanUpHook only stops the mock server in a @Before("@setup") hook, so the dedicated CucumberApiTest path (single @api scenario) starts the server in ApiSteps but never stops it after the scenario completes. Since MockApiServer runs with Executors.newSingleThreadExecutor(), this leaves a live non-daemon thread at the end of the test run and can hang non-forked JUnit/Cucumber executions (for example from IDE runs); move shutdown to an @After hook or another guaranteed teardown path.
Useful? React with 👍 / 👎.
Motivation
Description
@apitag to the third scenario insrc/test/resources/features/customer.featureso it can be filtered and run independently.CucumberApiTest(src/test/java/com/bank/bdd/runner/CucumberApiTest.java) that setsFILTER_TAGS_PROPERTY_NAMEto@apito run only the API scenario.MockApiServercomponent (src/test/java/com/bank/bdd/support/MockApiServer.java) to serve the/customer/statusPOST endpoint used by the API scenario.ApiSteps(src/test/java/com/bank/bdd/stepdefs/ApiSteps.java) to call the mock API, persist the API response intoCUSTOMER_API_RESPONSE, and assert status and source fields.ScenarioContext(src/test/java/com/bank/bdd/stepdefs/ScenarioContext.java) to carryapiResponseBodyandapiResponseStatusCodebetween steps.DBCleanUpHook(src/test/java/com/bank/bdd/hooks/DBCleanUpHook.java) to stop the mock server during setup and to create/drop theCUSTOMER_API_RESPONSEtable.CUSTOMER_API_RESPONSEcreation tosrc/test/resources/schema.sqland updatedREADME.mdto document the new API validation workflow.Testing
mvn -q -Dtest=CucumberApiTest test, which failed in this environment due to Maven dependency resolution error (non-resolvable parent POMorg.springframework.boot:spring-boot-starter-parent:4.0.1returning403 Forbidden), so tests could not be executed here.Codex Task