This is an integration test kit built with cucumber/godog.
It comes pre-configured with :
- Cucumber Godog (https://github.com/cucumber/godog
- Godog HTTP API (https://github.com/pawelWritesCode/godog-http-api)
Shout out to pawelWritesCode for the awesome work on godog-http-api!
To read available step definitions and documentation on how to use them, please read godog-http-api wiki.
To use this kit, you need to have godog and gocure installed on your machine.
For godog, use this command to install it:
$ go install github.com/cucumber/godog/cmd/godog@latest
For gocure, you can download the binary that fit to your os, extract the file from the release page and put it in your $PATH
directory.
Linux
$ cp gocure_linux_amd64 /usr/local/bin/gocure
$ export PATH=$PATH:/usr/local/bin/gocure
MacOS
$ cp gocure_darwin_amd64 /usr/local/bin/gocure
$ export PATH=$PATH:/usr/local/bin/gocure
If you can type godog
and gocure
in your terminal, you are good to go!
After that, you can create gherkin scenarios in features
folder.
Make sure to separate scenarios into different files based on the feature you are testing.
For further documentation about the step definitions, please read godog-http-api wiki.
To run the test, you need to make sure you have installed make
. If you don't have it installed on your machine, you can run this following command to install it:
Linux
$ sudo apt install make
macOS
$ brew install make
If you have installed make
don't forget to run the desired application in local environment!
For testing in the local environment, you can use go-grpc-starter repository to run an example test. To run the application, please read the documentation there.
If your application is not running in local environment, you can set the APP_URL
in the gherkin to the staging environment that have already deployed.
For example:
features/example/authentication.feature
...
Given I save "https://yourappsthathavealreadydeployed.com" as "APP_URL"
...
After that, you can run the tests with the following command:
$ make tests
If you want to test per feature, you can run the tests with the following command:
$ make test feature=example
To generate report, you can run the following command:
$ make generate.report
After that, you can open the report in report_xxx_xxx_xxx.html
file.
You can customize the test kit by adding your own step definitions. To add custom step definitions, you can add it in defs/scenario.go
.