gitlab.com/evatix-go/core@v1.3.55/coretests/SimpleGherkins.go (about) 1 package coretests 2 3 import ( 4 "gitlab.com/evatix-go/core/constants" 5 "gitlab.com/evatix-go/core/errcore" 6 ) 7 8 // SimpleGherkins 9 // 10 // https://www.guru99.com/gherkin-test-cucumber.html 11 // Feature: Login functionality of social networking site Facebook. 12 // Given: I am a facebook user. 13 // When: I enter username as username. 14 // And I enter the password as the password 15 // Then I should be redirected to the home page of facebook 16 // Given -> When -> Then 17 type SimpleGherkins struct { 18 Feature, 19 Given, 20 When, 21 Then, 22 Expect, 23 Actual string 24 } 25 26 func (it *SimpleGherkins) ToString(testIndex int) string { 27 return errcore.GherkinsString( 28 testIndex, 29 it.Feature, 30 it.Given, 31 it.When, 32 it.Then) 33 } 34 35 func (it *SimpleGherkins) String() string { 36 return it.ToString(constants.Zero) 37 } 38 39 func (it *SimpleGherkins) GetWithExpectation( 40 testIndex int, 41 ) string { 42 return errcore.GherkinsStringWithExpectation( 43 testIndex, 44 it.Feature, 45 it.Given, 46 it.When, 47 it.Then, 48 it.Actual, 49 it.Expect) 50 } 51 52 func (it *SimpleGherkins) GetMessageConditional( 53 isExpectation bool, 54 testIndex int, 55 ) string { 56 if isExpectation { 57 return it.GetWithExpectation(testIndex) 58 } 59 60 return it.ToString(testIndex) 61 }