Write a scenario
In order to write a scenario, you also need to declare environments and services you want to test.
Define a test environment🔗
Declare a target🔗
Under src/main/kotlin create a package (ex. fr.enedis.chutney.getstart) and create a Kotlin file (ex. Environments.kt) with the following content :
| Environments.kt | |
|---|---|
- The target name
search_engineis used as a reference in your scenarios - The
googlevariable is a reference to set a target in anenvironment
Declare an environment🔗
Now you can declare an environment within the same file, add the following content :
| Environments.kt | |
|---|---|
- We reference the target
googleusing the variable name. - The environment
nameanddescriptioncan be anything meaningful to you. The name will be shown in the execution report. - The variable name
environmentis a reference to set the environment on running tests
Define a test environment (alternative)🔗
There is another way to declare environments and targets by using JSON files.
Create a folder .chutney/environments in your project root folder.
Then, create a file environment.json with the following content :
An environment is already defined on your Chutney server?
If you have already defined an environment on your Chutney server, you can import it by calling synchroniseLocal function of EnvironmentSynchronizeService:
synchroniseLocal function parameters:
| name | type | Required | default | description |
|---|---|---|---|---|
serverInfo |
ChutneyServerInfo |
* | holds needed information to connect to chutney server | |
environmentsPath |
String |
.chutney/environments |
where to save the imported environments | |
force |
Boolean |
false |
if true, locally existing environments files will be overridden.Else they will be kept unchanged |
Write a scenario🔗
Under src/main/kotlin, in the same package or another, create a Kotlin file (ex. Scenarios.kt) with the following content :
- The scenario title
Search documentswill be shown in the execution report. - There are 2 steps
When I visit a search engineandThen I am on the front page - The first step will execute an HTTP GET call on the target name
search_engineon the uri/- It also has one validation
request acceptedto check the response code status is 200.
- It also has one validation
- The second step does nothing meaningful in this example
Et voilà !
You have successfully setup and written your first scenario using Chutney.
Now, you will see how to run it !