You can find an example script on our Github. First lets walk through the files and method used in the example:
- config.json – This is where you will configure your API Fortress Project names and their associated webhooks. This allows you to invoke the tests by simply passing the Project name in the feature file.
-
- apifun.feature – This is where you define the scenario and the steps using the Gherkin syntax. In this file you will define the Given, When, Then steps. In this example we pass in an API Fortress Project name in the “Given” step.
- Stepdefs.java – In this example we are using Java, however Cucumber supports many programming languages. The example file contains a few things:
- Stepdefs class
- In this class you will define what happens in each step from your feature file (Given, When, Then)
- Given – will take in the inputed Api Fortress Project name and call the getProjInfo method to get the webhook for this project
- When – will take the url of the webhook and call the callAPI method running all the API Fortress tests contained within that project
- Then – will parse through the response of the API Fortress webhook to provide the amount of failures, links to the API Fortress test results, and will indicate which tests passed and which failed
- getProjInfo method – This method will parse the config.json file and match the Project name provided in the Given step to the Project name defined in the config file. This method will then return the associated webhook.
-
- callAPI method – This method will take the webhook url from the When step and make a call to the API running all API Fortress tests within that project. This method will return the response from the API.
-
- Stepdefs class