Citrus Integration Testing ![Logo][1]

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.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.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));
}
}