How it works · Testing

One Gherkin spec, a unit test and an integration test

The same .feature file runs in-process against the real Chenile pipeline and against a deployed server. Swap the glue, not the spec.

One Gherkin specification, a unit test and an integration test An order.feature file is run two ways. As a unit test, the CukesRestTest runner uses the cucumber-utils glue: MockMvc sends the request in process through the real Chenile pipeline of order-service. As an integration test, the same file uses the it-cucumber-utils glue: REST Assured sends a real HTTP request to a deployed order-service. The same step sentences, implemented by RestCukesSteps in both libraries, build the request and check the response. order.feature Feature: Orders Scenario: create an order Given that "tenant" equals "acme" When I construct a REST request with header "x-chenile-tenant-id" and value "${tenant}" And I POST a REST request to URL "/order" with payload """{"item":"pen","qty":2}""" Then success is true And store "$.payload.id" from response to "orderId" src/test/resources/features mvn test · a unit test, in process CukesRestTestglue from cucumber-utils MockMvcno network order-service in the test JVM@SpringBootTest · chenile-highway → OrderServiceImpl One step vocabulary: org.chenile.cucumber.rest.RestCukesStepsthe same Gherkin sentences in cucumber-utils and it-cucumber-utils against a running server · an integration test CukesRestTestglue from it-cucumber-utils REST Assuredreal HTTP order-service, deployedchenile.bdd.target.host · chenile-highway → OrderServiceImpl
run as
view
Step 1

Exchange

Payload

🧪

Unit / component — cucumber-utils

Spring MockMvc stands the service up in an ephemeral in-process instance and drives it from the outside. Because the request passes through the real Chenile pipeline, it exercises the service and its interceptors — governance is under test. Fast enough for every build.

🌐

Integration — it-cucumber-utils · chenile-bdd

The identical scenarios run over REST Assured against a really deployed server, verifying the wire, packaging, config and environment. it-cucumber-sec-utils does the same for secured endpoints. Same spec, run against staging.

The test harness

Every test makes the whole call, with the policies on

Chenile does not test a method in isolation. A test sends an HTTP request through the real pipeline, with the same interceptors the deployed service runs, and can bring up real brokers and an identity provider. The harness for all of it comes with Chenile.

Its own Chenile configuration

A service's tests load their own Chenile properties: TestService.properties points chenile.properties at TestService-chenile.properties, which sets the test monolith name, the service definitions and the interceptors. With security on, it sets chenile.post.processors=securityInterceptor, so every test request is checked like a production one.

MockMvc, not a method call

The request goes through Spring MVC, the Chenile entry point and every interceptor, in a Spring test context, without opening a port. Request binding, headers, security, tenancy and the GenericResponse envelope are all under test, which a plain JUnit test of the service class never reaches.

Real infrastructure, by inheritance

Extend a base class and Testcontainers starts the real thing, then points the test's configuration at it:

  • KafkaBaseTest: a Kafka broker; sets spring.kafka.bootstrap-servers
  • MqttBaseTest: a HiveMQ broker; sets pubsub.mqtt.connection.ServerURIs
  • BaseSecurityTest: a Keycloak with realms tenant0 and tenant1, each with a normal and a premium user
// A Kafka-backed service test: inherit the broker
public class TestKafka extends KafkaBaseTest { … }

// A secured scenario gets a real token from the container
When I construct a REST request with authorization header
     in realm "tenant0" for user "t0-premium" and password "t0-premium"
And I POST a REST request to URL "/order" with payload
"""
{"item":"pen","qty":2}
"""
Then success is true

Where they live

KafkaBaseTest and MqttBaseTest are in cucumber-mqtt-utils (chenile-messaging, package org.chenile.mqtt.test); BaseSecurityTest and the security steps are in cucumber-sec-utils (chenile-security). JGen's process management blueprint generates server and worker tests that already extend KafkaBaseTest. Generated service tests use an in-memory H2 database by default; Testcontainers can run a real one too, as the JDBC query catalog's PostgreSQL tests do.