github.com/maps90/godog@v0.7.5-0.20170923143419-0093943021d4/features/snippets.feature (about) 1 Feature: undefined step snippets 2 In order to implement step definitions faster 3 As a test suite user 4 I need to be able to get undefined step snippets 5 6 Scenario: should generate snippets 7 Given a feature "undefined.feature" file: 8 """ 9 Feature: undefined steps 10 11 Scenario: get version number from api 12 When I send "GET" request to "/version" 13 Then the response code should be 200 14 """ 15 When I run feature suite 16 Then the following steps should be undefined: 17 """ 18 I send "GET" request to "/version" 19 the response code should be 200 20 """ 21 And the undefined step snippets should be: 22 """ 23 func iSendRequestTo(arg1, arg2 string) error { 24 return godog.ErrPending 25 } 26 27 func theResponseCodeShouldBe(arg1 int) error { 28 return godog.ErrPending 29 } 30 31 func FeatureContext(s *godog.Suite) { 32 s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo) 33 s.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe) 34 } 35 """ 36 37 Scenario: should generate snippets with more arguments 38 Given a feature "undefined.feature" file: 39 """ 40 Feature: undefined steps 41 42 Scenario: get version number from api 43 When I send "GET" request to "/version" with: 44 | col1 | val1 | 45 | col2 | val2 | 46 Then the response code should be 200 and header "X-Powered-By" should be "godog" 47 """ 48 When I run feature suite 49 Then the undefined step snippets should be: 50 """ 51 func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error { 52 return godog.ErrPending 53 } 54 55 func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error { 56 return godog.ErrPending 57 } 58 59 func FeatureContext(s *godog.Suite) { 60 s.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith) 61 s.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe) 62 } 63 """ 64 65 Scenario: should handle escaped symbols 66 Given a feature "undefined.feature" file: 67 """ 68 Feature: undefined steps 69 70 Scenario: get version number from api 71 When I pull from github.com 72 Then the project should be there 73 """ 74 When I run feature suite 75 Then the following steps should be undefined: 76 """ 77 I pull from github.com 78 the project should be there 79 """ 80 And the undefined step snippets should be: 81 """ 82 func iPullFromGithubcom() error { 83 return godog.ErrPending 84 } 85 86 func theProjectShouldBeThere() error { 87 return godog.ErrPending 88 } 89 90 func FeatureContext(s *godog.Suite) { 91 s.Step(`^I pull from github\.com$`, iPullFromGithubcom) 92 s.Step(`^the project should be there$`, theProjectShouldBeThere) 93 } 94 """ 95 96 Scenario: should handle string argument followed by comma 97 Given a feature "undefined.feature" file: 98 """ 99 Feature: undefined 100 101 Scenario: add item to basket 102 Given there is a "Sith Lord Lightsaber", which costs £5 103 When I add the "Sith Lord Lightsaber" to the basket 104 """ 105 When I run feature suite 106 And the undefined step snippets should be: 107 """ 108 func thereIsAWhichCosts(arg1 string, arg2 int) error { 109 return godog.ErrPending 110 } 111 112 func iAddTheToTheBasket(arg1 string) error { 113 return godog.ErrPending 114 } 115 116 func FeatureContext(s *godog.Suite) { 117 s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts) 118 s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) 119 } 120 """ 121 122 Scenario: should handle arguments in the beggining or end of the step 123 Given a feature "undefined.feature" file: 124 """ 125 Feature: undefined 126 127 Scenario: add item to basket 128 Given "Sith Lord Lightsaber", which costs £5 129 And 12 godogs 130 """ 131 When I run feature suite 132 And the undefined step snippets should be: 133 """ 134 func whichCosts(arg1 string, arg2 int) error { 135 return godog.ErrPending 136 } 137 138 func godogs(arg1 int) error { 139 return godog.ErrPending 140 } 141 142 func FeatureContext(s *godog.Suite) { 143 s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) 144 s.Step(`^(\d+) godogs$`, godogs) 145 } 146 """