Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

To Execute Tests in Jenkins

In this procedure, you create a Jenkinsfile in your test directory that includes a function call:

apiTests()

This function can optionally take an argument, such as the location of the tests.

You upload the contents of your test directory to Jenkins and BAT executes tests when the function is called. The Jenkinsfile in the bat.demo repo includes configuration code that identifies the location of a test repository.

The apiTests function calls the class pipeline.groovy inside the alfred project:

https://github.com/mulesoft/alfred/blob/master/pipeline.groovy.

A groovy script executes that downloads the latest version of the BAT wrapper and runs the test project with the distribution.

To execute tests in Jenkins:

  1. Create a named Jenkinsfile in your test directory at the same level as bat.yaml. For example:

    bat jenkins file

  2. In Jenkinsfile, call apiTests:

    #!groovy
    
    apiTests()
  3. Upload the contents of your test directory to Jenkins.

    Bat executes tests in your test directory on Jenkins. If your bat.raml includes a cron expression, tests run repeatedly as specified.