Tentang
Framework for automated integration tests with focus on message-based applications
Pengembangan web dan aplikasiPertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- 0
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliCitrus Integration Testing 
Welcome to Citrus
Citrus is a test framework written in Java that provides a complete test automation tool for integration testing of message-based enterprise applications.
The framework supports a huge set of different message transports and protocols like Http REST, Kafka, JMS, TCP/IP, FTP, SOAP Web Services.
In addition to that Citrus integrates with many technologies and libraries such as Apache Camel, Spring, Quarkus, Testcontainers, Kubernetes, Knative, Selenium and many more.
For validation purpose Citrus is able to verify many different message data formats and protocols such as XML, Json, YAML, CSV, Plaintext, SQL ResultSet and more.
Visit the official website at 'https://citrusframework.org' for more information and a detailed documentation.
Quickstart
Learn how to create and run Citrus integration tests in just a few minutes. You can choose from a set of supported runtimes (JUnit, TestNG, Quarkus, SpringBoot, JBang) and domain specific languages (Java, XML, YAML, Groovy, Cucumber).
For a full guide how to get started with Citrus please visit the quickstart section on the official website.
The easiest way to create and run a Citrus test without a project setup is to use the Citrus JBang support.
You can just call this command to create a new test.
jbang citrus@citrusframework/citrus init MyTest.java
The init command creates a new file that represents a Citrus test. The file extension used defines the test source language. You can choose one of the supported test source languages .java, .xml, .yaml, .groovy, .feature.
The result looks like this:
import org.citrusframework.dsl.TestActionSupport;
import org.citrusframework.TestCaseRunner;
import org.citrusframework.annotations.CitrusResource;
public class MyTest implements Runnable, TestActionSupport {
@CitrusResource
TestCaseRunner t;
@Override
public void run() {
t.given(
createVariables().variable("message", "Citrus rocks!")
);
t.then(
echo().message("${message}")
);
}
}
You can now just run the test without any project setup using the Citrus JBang run command:
jbang citrus@citrusframework/citrus run MyTest.java
You may also install the Citrus JBang app to simplify the command line tooling:
jbang trust add https://github.com/citrusframework/citrus/
jbang app install citrus@citrusframework/citrus
Now you can just call:
citrus init my.citrus.it.yaml
citrus run my.citrus.it.yaml
A more complex Citrus integration test typically uses messaging endpoints to send and receive messages with different messaging transports.
A typical Citrus Java JUnit Jupiter test may look like this:
import org.citrusframework.TestCaseRunner;
import org.citrusframework.dsl.TestActionSupport;
import org.citrusframework.annotations.CitrusResource;
import org.citrusframework.annotations.CitrusTest;
import org.citrusframework.junit.jupiter.CitrusSupport;
import org.junit.jupiter.api.Test;
@CitrusSupport
public class HelloServiceIT implements TestActionSupport {
@CitrusResource
private TestCaseRunner t;
@Test
@CitrusTest
public void shouldSayHello() {
t.when(
http().client("http://localhost:8080/test")
.send()
.post()
.contentType("text/plain")
.body("Hello from Citrus!")
);
t.then(
receive().endpoint("kafka:my-topic")
.message()
.body("Hello from Citrus!")
);
t.and(
http().client("http://localhost:8080/test")
.receive()
.response(HttpStatus.OK));
}
}
As you can see the test leverages several Citrus features like sending/receiving messages with different message transports. Receiving a message always comes with an expected message content, so Citrus performs a powerful message validation on body and header content. Citrus is able to handle different message types such as XML, Json, Plaintext, YAML, CSV and more.
You can easily integrate the test into your project with Maven, or you can just run the test without any project setup with JBang.
citrus run HelloServiceIT.java
For AI agents
If you are an AI agent writing Citrus tests in YAML or XML, start here:
YAML test case JSON schema - Use this schema for validation and auto-completion:
https://citrusframework.org/schema/json/testcase/citrus-testcase.jsonAdd the schema line at the top of every YAML test:# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.jsonXML test case XSD schemas - For XML tests use the namespace and schema location:
http://citrusframework.org/schema/xml/testcasewithhttp://citrusframework.org/schema/xml/testcase/citrus-testcase.xsdProtocol-specific XSDs follow the patterncitrus-<protocol>-testcase.xsd(e.g.citrus-http-testcase.xsd,citrus-kafka-testcase.xsd).Action and endpoint catalogs - Machine-readable JSON catalogs with descriptions, property schemas, and test variables for all actions, containers, and endpoints:
https://citrusframework.org/schema/catalog/<version>/citrus-catalog-aggregate-test-actions.jsonhttps://citrusframework.org/schema/catalog/<version>/citrus-catalog-aggregate-endpoints.jsonMCP server -
tools/mcp-serverprovides tool-based access to the catalogs and test scaffolding.Claude Code plugin -
plugins/citrus-mcpintegrates the MCP server with Claude Code.LLM overview -
https://citrusframework.org/llms.txt(see llmstxt.org)
YAML test examples
Minimal, correct examples that can be run with citrus run <file> (JBang, no project setup required).
Very simple test printing a log message with variables
# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.json
name: SimpleTest
variables:
- name: user
value: Citrus
actions:
- echo:
message: "Hello ${user}"
Send and receive a plaintext message via a direct endpoint
# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.json
name: DirectMessageTest
endpoints:
- direct:
name: greets
autoCreateQueue: true
queue: greetings
actions:
- send:
endpoint: greets
message:
body:
data: "Hello from Citrus!"
- receive:
endpoint: greets
message:
body:
data: "Hello from Citrus!"
HTTP GET request with JSON response validation
# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.json
name: HttpGetJsonTest
actions:
- http:
client: "httpClient"
sendRequest:
uri: "http://localhost:8080/test"
GET: {}
- http:
client: "httpClient"
receiveResponse:
response:
status: "200"
body:
data: '{"message": "Hello World!"}'
Start Kafka with Testcontainers, run a Camel integration, send and receive Kafka messages, verify the Camel log
# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.json
name: KafkaCamelIT
description: Start Kafka, run Camel route, verify messages and log output
actions:
- testcontainers:
start:
kafka:
topics:
- "simple-topic"
- camel:
cli:
run:
integration:
name: "simple-route"
file: "simple-route.yaml"
- send:
endpoint: "kafka:simple-topic"
message:
body:
data: "Hello Kafka!"
- receive:
endpoint: "kafka:processed-topic"
message:
body:
data: "Citrus said: Hello Kafka!"
- camel:
cli:
verify:
integration: "simple-route"
logMessage: "Inbound message: Hello Kafka!"
Start PostgreSQL with Testcontainers, send an HTTP POST, verify the DB insert
# yaml-language-server: $schema=https://citrusframework.org/schema/json/testcase/citrus-testcase.json
name: HttpPostgresIT
description: Start PostgreSQL, send HTTP POST, verify DB entry
actions:
- testcontainers:
start:
postgresql:
database: testdb
username: test
password: test
dataSourceName: usersDS
initScript:
value: |
CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name VARCHAR, email VARCHAR);
- http:
client: "http://localhost:8080/api/users"
sendRequest:
POST:
body:
data: '{"name": "Jane", "email": "[email protected]"}'
- http:
client: "http://localhost:8080/api/users"
receiveResponse:
response:
status: "201"
- sql:
dataSource: "usersDS"
statements:
- statement: SELECT name FROM users WHERE email='[email protected]'
validate:
- column: name
value: Jane
The testcontainers: start: postgresql action sets test variables CITRUS_TESTCONTAINERS_POSTGRESQL_HOST, _PORT, _URL, etc. that you can reference with ${CITRUS_TESTCONTAINERS_POSTGRESQL_URL}.
The testcontainers: start: kafka action sets CITRUS_TESTCONTAINERS_KAFKA_BOOTSTRAP_SERVERS etc.
Developing
The following software is recommended in order to code with the Citrus framework:
Java 21+ Installed JDK plus JAVA_HOME environment variable set up and pointing to your Java installation directory. Used to compile and build the Citrus code.
Maven 3.9.8+ Citrus projects will fit best with Maven. However, it is not required to use Maven. You can also run tests using Gradle for instance.
Java IDE (optional) A Java IDE will help you to manage your Citrus project (e.g. creating and executing test cases). You can use the Java IDE that you like best like Eclipse or IntelliJ IDEA.
JBang (optional) For fast prototyping you can use the Citrus JBang app as a command line tooling. It allows you to create and run Citrus tests without a project setup. Dependencies and Java runtime setup is automatically managed by JBang.
Samples
Our sample section is still growing. You can find several sample projects in the separate repository citrusframework/citrus-samples.
Support
In case you need help and support for Citrus have a look at
https://citrusframework.org/help.
Contact [email protected] directly for any request or questions.
Issues
Please report any bugs and/or feature requests directly to citrusframework/citrus/issues
Resources
Clone the code repository https://github.com/citrusframework/citrus.git with Git to run the Maven build on your machine to get a fresh copy of the latest bits.
Find our blog and news articles about Citrus and checkout the various post categories for selecting a specific topic.
The official website https://citrusframework.org offers tutorials and more information about Citrus.
Review the individual release notes to learn about the changes for a release. For detailed description of changed packages and classes do also consult the GitHub commit history.
License
Copyright 2006-2025 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Information
For more information on Citrus see citrusframework.org, including a complete reference manual.
Jelajahi proyek terkait
Memuat…