Finally, Lg5 supports Cucumber integration with Spring Boot 3, Testcontainers, and reuses many configurations for testing. This way, you can create acceptance tests for your domain services quickly.
Before continuing, you will need to have the docker image of your app.
If not, remember to add the jib plugin in the container module or generate the docker image in another way.
Once you have the docker image, you can continue.
Feature: I as a customer want to create a blank using the repository templateScenario: the blank should be CREATED when use the repository template Given a repository templateWhen blank is createdThen the blank will be created using the repository template
Recommended following Acceptance Test Drive Development allowed to align main goals for one or more user's needs.
Using the traditional workflow ATDD, you need to define acceptance criteria using Gherkin syntax (Given, When, Then).
You need to add the following Dependency and Java classes to your acceptance test. So, you can try the dockerized domain service.
For more details, read more about Hexagonal Architecture(Spanish).
Dependencies:
Lg5 tries to simplify dependencies but the power is the same. π
Feature: I as a customer want to create a blank using the repository templateScenario: the blank should be CREATED when use the repository template Given a repository templateWhen blank is createdThen the blank will be created using the repository template
importio.cucumber.java.en.Given;importio.cucumber.java.en.Then;importio.cucumber.java.en.When;publicclassMyStepdefs{@Given("a repository template")publicvoidaRepositoryTemplate(){}@When("blank is created")publicvoidblankIsCreated(){}@Then("the blank will be created using the repository template")publicvoidtheBlankWillBeCreatedUsingTheRepositoryTemplate(){}}
With destination.path: ./target/logs where stored logs file from blank-service after that tests finished.
Replace some name by your system and domain name: blanksystem and blank.
if you use some TestContainer CustomConfig enabled, you would added the following properties for each one:
* Postgres Container
* Add liquibase files with migrations.
* Kafka Container
* `${kafka-config.bootstrap-servers}`
* SchemaRegistry Container
* `${kafka-config.schema-registry-url}`
* KAFKA MODELS
* If you must have kafka models, So, CREATE AVRO DIRECTORY For instance: `src/test/resources/avro/example.avsc`
* Wiremock Container
* Specify third system url `${wiremock.config.url}`.
* Indicate a port binding to connect: `${wiremock.config.port}`.
* Directory where stored the mock req/res http `${wiremock.config.folder}`.
* CREATE WIREMOCK DIRECTORY and a TEMPLATE base, For instance: `src/test/resources/wiremock/third_system/template.json`.
<dependencies>...
<!-- if you need to connect a database--><dependency><groupId>com.lg5.spring</groupId><artifactId>lg5-spring-data-jpa</artifactId></dependency><!-- if you need to generate models--><dependency><groupId>com.lg5.spring.kafka</groupId><artifactId>lg5-spring-kafka-model</artifactId></dependency><!-- if you need to produce events--><dependency><groupId>com.lg5.spring.kafka</groupId><artifactId>lg5-spring-kafka-producer</artifactId></dependency><!-- if you need to consume events--><dependency><groupId>com.lg5.spring.kafka</groupId><artifactId>lg5-spring-kafka-consumer</artifactId></dependency>...
</dependencies>...
<build><plugins><!-- if you need to generate models--><plugin><groupId>org.apache.avro</groupId><artifactId>avro-maven-plugin</artifactId></plugin></plugins></build>