Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dpakach/gobdd
A Gherkin test runner for golang
https://github.com/dpakach/gobdd
Last synced: about 1 month ago
JSON representation
A Gherkin test runner for golang
- Host: GitHub
- URL: https://github.com/dpakach/gobdd
- Owner: dpakach
- License: mit
- Created: 2020-02-15T13:45:57.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T08:29:46.000Z (almost 5 years ago)
- Last Synced: 2024-10-28T13:17:24.249Z (3 months ago)
- Language: Go
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goBDD
A BDD based test runner for golang## Getting Started
1. First install goBDD in your project or test infrastructure
```bash
go get -u github.com/dpakach/goBDD
```
2. Create a feature file for your project. For writing feature files we use the [gherkin language](https://cucumber.io/docs/gherkin/). Use [this](https://cucumber.io/docs/gherkin/reference/) reference from cucumber.io to write your feature files.
Here is a simple example of a feature file
```gherkin
Feature: Some featureScenario: An example scenario
When I do "BDD"
Then my project has less bugs
```
The feature should match the feature you want to test and the scenario should be an example of that feature described using the gherkin specification.3. Create a go program that contains the definitions for your gherkin steps. You can write your step definitions to do any action or assertions for your tests.
Here is an example of a simple step definitions file.
``` go
package mainimport (
"fmt""github.com/dpakach/goBDD/runner"
"github.com/dpakach/goBDD/suite"
)func main() {
s := suite.NewSuite()s.When("I do {{s}}", func(task string) {
fmt.Printf("I am doing %v\n", task)
})s.Then("my project has less bugs", func() {
fmt.Println("congrats! Your project has less bugs now.")
})
runner.Run(s)
}```
Here we are just printing some text on the stdOut but you can do anything you want in the step definitions. You can call functions from your project and test their results, make api calls and test the api response or even integrate a selenium driver and perform UI tests on your project.
4. Now to run the tests go to the terminal and run the go program.
``` bash
go run main.go [path/to/your/feature/files]
```## License
Copyright (c) 2020 Dipak Acharya
Licensed under [MIT License](https://github.com/dpakach/goBDD/blob/master/LICENSE)