Skip to content

synchronize

Synchronize your kotlin scenario with a server🔗

Create your Kotlin scenario locally🔗

Follow this documentation to write your first Kotlin scenario.

Create your scenario on chutney server🔗

To create your scenario on a Chutney server from your IDE,

  1. Annotate with @Scenario In order to be included in the synchronization, a scenario must be annotated with @Scenario.
  2. Configure your server info

    1
    2
    3
    4
    5
    6
    7
    import com.chutneytesting.kotlin.synchronize.synchronise
    import com.chutneytesting.kotlin.util.ChutneyServerInfo
    
    val chutneyLocalServer = ChutneyServerInfo(
        url = "http://localhost:8081", user = "admin", password = "admin",
        proxyUrl = "http://my.proxy.host:3128", proxyUser = "user", proxyPassword = "pwd" // (1)!
    )
    

    1. Proxy connection configuration is not mandatory.
      It can be also set with corresponding Java System properties.
      [ http | https ].[ proxyHost | proxyPort | proxyUser | proxyPassword ]
  3. Execute a main to call synchronise function on your scenario

    1
    2
    3
    fun main() {
        synchronizeScenarios(packageName = "your.package.name", updateRemote = true, serverInfo = chutneyLocalServer) // (1)!
    }
    

    1. See logs generated by synchronize function in your console to get more details of what it did.

    This will create a new scenario on the given chutney server.
    Then it will create a json file that contains the json representation of the scenario.

    json file name

    The json file name format is : {ID} - {scenario title} .chutney.json
    In our example it will be something like: 123456-Search documents.chutney.json

    synchronise function parameters

    name type Required default description
    serverInfo ChutneyServerInfo null holds needed information to connect to chutney server.
    updateRemote Boolean false if true, the given scenario will be created if it doesn't exist and updated if it does.
    path String src/main/chutney/generated path where to generate scenarios json files.
    block SynchronizeScenariosBuilder.() -> Unit all scenario annotated with @Scenario Define which scenarios will be synchronized.
  4. Refer the generated ID in your scenario constructor:

    where to find the generated ID ?

    As explained above, the generated ID is in the created json file's name (123456-Search documents.chutney.json).

    val first_scenario = Scenario(id = 123456, title = "Search documents") {
        When("I visit a search engine") {
            HttpGetAction(
                    target = "search_engine",
                    uri = "/"
            )
        }
        Then("I am on the front page") {
            SuccessAction()
        }
    }
    

    Now your scenario is created on the server !

Update your scenario on chutney server🔗

After editing your scenario kotlin code, jut call synchronize function again.

Don't forget !

Don't forget to call synchronize with updateRemote = true

Now your scenario is updated on Chutney server !

Synchronize from your integration server

  • Push Kotlin scenarios source code to a centralized repository hosted on your SCM server (github, gitlab, bitbucket...).
  • Call synchronize main from an integration server(jenkins, gitlab CI, github actions...) to update scenarios on your remote Chutney instance.
  • Synchronize call can be scheduled just before running your test campaigns to have up-to-date scenarios.

Configure your environment on the server🔗

Now, the last step before running your scenario from the server is to setup environments and targets.

Create an environment

To manage environments on a server, you can :

  • Use the UI forms to create or import environments.
  • Copy an existing environment file into the server configuration folder (default is .chutney/conf/environment)