Running unit tests

Java Node Python . . .

Running unit and integration tests with ElasTest doesn't require launching beforehand a SuT. The test itself will manage the execution of the tested software. So the only requirment is to create a TJob and launch it. Here we will run our Unit Java Test:

Class to test

public class Calc {

    public int sum(int a, int b) {
        return a + b;


Unit test

public class CalcTest {

    private Calc calc;

    public void init() {
        this.calc = new Calc();

    public void sumTest() {


When a TJob is created, the minimum information that you have to provide is the following:

  • TJob Name: name of the TJob
  • Select a SuT: None
  • Environment docker image: the docker image that will host your test. This docker images should contain a client to download your code from your repository hosting service. For example, if your tests are hosted in GitHub and implemented in a Maven project with Java, you need to include a git client, Maven and the Java Development Kit (JDK) in the image. Indeed, the image elastest/test-etm-alpinegitjava contains Git, Maven and Java.
  • Commands: these are the bash commands to be executed to download the code from a repository and to execute the tests. The specific commands depends on the source code repository type and the technology. For example, the following commands will clone a Maven/Java repository from GitHub and execute the tests:
    git clone
    cd demo-projects/unit-java-test
    mvn test

Immediately after, the execution view will open automatically. You will see your logs and metrics in real time.

Your test will finish at some point: you can see the final entries in the "Test Logs" card and the TJob status changing to SUCCESS, FAIL, STOPPED or ERROR depending on the final result.