Write your first scenario
In order to write a scenario, you also need to declare environments and services you want to test.
Define your test environment🔗
Declare a target🔗
Under src/main/kotlin
create a package (ex. com.chutneytesting.getstart
) and create a Kotlin file (ex. Environments.kt
) with the following content :
Environments.kt | |
---|---|
- The target name
search_engine
is used as a reference in your scenarios - The
google
variable 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
google
using the variable name. - The environment
name
anddescription
can be anything meaningful to you. The name will be shown in the execution report. - The variable name
environment
is a reference to set the environment on running tests
Define your 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 documents
will be shown in the execution report. - There are 2 steps
When I visit a search engine
andThen I am on the front page
- The first step will execute an HTTP GET call on the target name
search_engine
on the uri/
- It also has one validation
request accepted
to 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 !