Skip to content

Add @api tag and dedicated Cucumber runner; implement Mock API steps and DB support#2

Open
SimRaina wants to merge 2 commits into
codex/use-embedded-kafka-instead-of-local-setupfrom
codex/add-api-request/response-capability
Open

Add @api tag and dedicated Cucumber runner; implement Mock API steps and DB support#2
SimRaina wants to merge 2 commits into
codex/use-embedded-kafka-instead-of-local-setupfrom
codex/add-api-request/response-capability

Conversation

@SimRaina

Copy link
Copy Markdown
Owner

Motivation

  • Enable running the third feature scenario (API validation) in isolation by tagging it and providing a focused JUnit/Cucumber runner.
  • Provide test support for an in-process mock API and persistence so the API scenario can execute end-to-end against a reproducible test server and DB table.
  • Ensure test DB schema and test lifecycle hooks include storage for API responses so assertions can be made against persisted data.

Description

  • Added an @api tag to the third scenario in src/test/resources/features/customer.feature so it can be filtered and run independently.
  • Added a dedicated JUnit/Cucumber test suite CucumberApiTest (src/test/java/com/bank/bdd/runner/CucumberApiTest.java) that sets FILTER_TAGS_PROPERTY_NAME to @api to run only the API scenario.
  • Implemented a lightweight MockApiServer component (src/test/java/com/bank/bdd/support/MockApiServer.java) to serve the /customer/status POST endpoint used by the API scenario.
  • Added step definitions in ApiSteps (src/test/java/com/bank/bdd/stepdefs/ApiSteps.java) to call the mock API, persist the API response into CUSTOMER_API_RESPONSE, and assert status and source fields.
  • Extended ScenarioContext (src/test/java/com/bank/bdd/stepdefs/ScenarioContext.java) to carry apiResponseBody and apiResponseStatusCode between steps.
  • Updated DBCleanUpHook (src/test/java/com/bank/bdd/hooks/DBCleanUpHook.java) to stop the mock server during setup and to create/drop the CUSTOMER_API_RESPONSE table.
  • Added CUSTOMER_API_RESPONSE creation to src/test/resources/schema.sql and updated README.md to document the new API validation workflow.

Testing

  • Attempted targeted test execution with mvn -q -Dtest=CucumberApiTest test, which failed in this environment due to Maven dependency resolution error (non-resolvable parent POM org.springframework.boot:spring-boot-starter-parent:4.0.1 returning 403 Forbidden), so tests could not be executed here.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 16 to +18
@Before("@setup")
public void cleanDb() {
mockApiServer.stop();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant