Skip to content

chutney-testing/chutney-project-template

Repository files navigation

Getting started with Chutney

build

Setup your project

use this template
  • Git clone your new GitHub repository (complete documentation)

  • Execute scenarios :

    • ./mvnw clean verify

    • ./gradlew clean test

      Or, if you are a Windows user:

    • mvnw.bat clean verify

    • gradlew.bat clean test

For the next section, we recommend that you open the project with a Java IDE such as IntelliJ.

seven Whaaat’s in the booox ?

A sample scenarios, in there you will find 4 scenarios :

  • One call a search engine and another one call a chutney website

    • They both show how to reference a target, decoupled from any environment (see next section)
      If you look closely, there is no reference to google.fr or google.com nor any other URLs.
      Instead, there is a reference to an abstract target: search_engine or chutney.
      This reference allows the same scenario to run on different environments without being couple to technical details such as URLs, authentication etc.

    • The first scenario also shows how to do an assertion from a "business" point of view, using a separate step

    • The second scenario shows how to do an assertion from a "technical" point of view, using an inner step validation

  • One scenario call an non existing website

    • It is called in LauncherTest to show how to expect a step failure using the Launcher

  • The last scenario shows how to pass parameters

Using multiple environment

  • Open the Environments.kt file.

  • Look at the en_search_engine and fr_search_engine values. The later is a copy, so they share the same name: "search_engine" but have different URL.
    Then, they are set in different environment, respectively english_web and french_web.

  • With the same scenario, you can execute the http get action on target search_engine on two different environments

 HttpGetAction(
    target = "search_engine",
    uri = "/",
    validations = mapOf("request accepted" to "status == 200".spEL()),
    outputs = mapOf("resultJson" to "body".spEL())
)

Executing on multiple environments

The same scenario without a single modification was run on a different environment.

💡

Usually, an environment represents the different stages used to qualify a software, such as local, dev, staging or pre-production.

  • Now, if we want our scenario to run on each environment, we can take advantage of @ParameterizedTest supplied by JUnit Jupiter

  • Look at example in LauncherTest.kt

Starting with a Chutney server

Until then, we worked with the embedded version of Chutney which does not need a server. This fits well within a CI or for a developer local setup.

However, building software is most often a teamwork !
Doing so, you will need to collaborate and share scenarios, track their executions and allow functional and business analyst to review and be involved in testing their product.

To allow that, Chutney provides a server version, composed of the execution engine and a UI.

  • Start Chutney locally by running docker compose up& (Docker compose documentation).

  • Access the UI at the address: https://localhost

  • Login using the default credentials admin / admin

  • Create your first scenario in the UI by clicking on the pen icon in the upper right

  • Save it as is, by clicking on the save button

  • Run it by clicking on the run button and choosing the environment on which to run the scenario against

💡

The dockerized Chutney already knows the aforementioned environments, as the folder chutney_environments is mounted as its root directory in the docker-compose.yml file.

Synchronizing Kotlin scenarios with a server

  • Open the SynchronizeToServer.kt file

  • Execute the main function to synchronize any change made locally to the running server

💡

To synchronize a scenario, the test code has to share an id with the server in order to know what scenario to update. The id is provided in the constructor of Scenario: Scenario(id = 1, title = "Search title displays").