goBDD

所属分类:collect
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2020-03-10 08:29:46
上 传 者sh-1993
说明:  golang的小黄瓜试跑选手,
(A Gherkin test runner for golang,)

文件列表:
LICENSE (1070, 2020-03-10)
examples/ (0, 2020-03-10)
examples/main.go (895, 2020-03-10)
examples/test.feature (428, 2020-03-10)
go.mod (111, 2020-03-10)
go.sum (1718, 2020-03-10)
runner/ (0, 2020-03-10)
runner/runner.go (1354, 2020-03-10)
suite/ (0, 2020-03-10)
suite/suite.go (5357, 2020-03-10)

# 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 feature Scenario: 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 main import ( "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)

近期下载者

相关文件


收藏者