How to use NewConceptDictionary method of gauge Package

Best Gauge code snippet using gauge.NewConceptDictionary

refactor_test.go

Source: refactor_test.go Github

copy

Full Screen

...27 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},28 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},29 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3},30 }31 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")32 agent, errs := getRefactorAgent(oldStep, newStep, nil)33 specs := append(make([]*gauge.Specification, 0), spec)34 agent.rephraseInSpecsAndConcepts(&specs, gauge.NewConceptDictionary())35 c.Assert(len(errs), Equals, 0)36 c.Assert(len(specs[0].Scenarios[0].Steps), Equals, 1)37 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, newStep)38}39func (s *MySuite) TestRefactoringOfStepsWithNoArgsAndWithMoreThanOneScenario(c *C) {40 oldStep := "first step"41 newStep := "second step"42 unchanged := "unchanged"43 tokens := []*parser.Token{44 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},45 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},46 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3},47 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 5},48 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 20},49 &parser.Token{Kind: gauge.StepKind, Value: unchanged, LineNo: 30},50 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 50},51 }52 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")53 agent, errs := getRefactorAgent(oldStep, newStep, nil)54 specs := append(make([]*gauge.Specification, 0), spec)55 agent.rephraseInSpecsAndConcepts(&specs, gauge.NewConceptDictionary())56 c.Assert(len(errs), Equals, 0)57 c.Assert(len(specs[0].Scenarios), Equals, 2)58 c.Assert(len(specs[0].Scenarios[0].Steps), Equals, 2)59 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, newStep)60 c.Assert(specs[0].Scenarios[0].Steps[1].Value, Equals, newStep)61 c.Assert(len(specs[0].Scenarios[1].Steps), Equals, 2)62 c.Assert(specs[0].Scenarios[1].Steps[0].Value, Equals, unchanged)63 c.Assert(specs[0].Scenarios[1].Steps[1].Value, Equals, newStep)64}65func (s *MySuite) TestRefactoringOfStepsWithNoArgsAndWithMoreThanOneSpec(c *C) {66 oldStep := " first step"67 newStep := "second step"68 tokens := []*parser.Token{69 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},70 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},71 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3},72 }73 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")74 tokens = []*parser.Token{75 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 10},76 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 20},77 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 30},78 }79 spec1, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")80 specs := append(make([]*gauge.Specification, 0), spec)81 specs = append(specs, spec1)82 agent, errs := getRefactorAgent(oldStep, newStep, nil)83 specRefactored, _ := agent.rephraseInSpecsAndConcepts(&specs, gauge.NewConceptDictionary())84 for _, isRefactored := range specRefactored {85 c.Assert(true, Equals, isRefactored)86 }87 c.Assert(len(errs), Equals, 0)88 c.Assert(len(specs[0].Scenarios[0].Steps), Equals, 1)89 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, newStep)90 c.Assert(len(specs[1].Scenarios[0].Steps), Equals, 1)91 c.Assert(specs[1].Scenarios[0].Steps[0].Value, Equals, newStep)92}93func (s *MySuite) TestRefactoringOfStepsWithNoArgsInConceptFiles(c *C) {94 oldStep := "first step"95 newStep := "second step"96 unchanged := "unchanged"97 tokens := []*parser.Token{98 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},99 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 20},100 }101 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")102 agent, _ := getRefactorAgent(oldStep, newStep, nil)103 specs := append(make([]*gauge.Specification, 0), spec)104 dictionary := gauge.NewConceptDictionary()105 step1 := &gauge.Step{Value: oldStep + "sdsf", IsConcept: true}106 step2 := &gauge.Step{Value: unchanged, IsConcept: true, Items: []gauge.Item{&gauge.Step{Value: oldStep, IsConcept: false}, &gauge.Step{Value: oldStep + "T", IsConcept: false}}}107 dictionary.ConceptsMap[step1.Value] = &gauge.Concept{ConceptStep: step1, FileName: "file.cpt"}108 dictionary.ConceptsMap[step2.Value] = &gauge.Concept{ConceptStep: step2, FileName: "file.cpt"}109 agent.rephraseInSpecsAndConcepts(&specs, dictionary)110 c.Assert(dictionary.ConceptsMap[unchanged].ConceptStep.Items[0].(*gauge.Step).Value, Equals, newStep)111 c.Assert(dictionary.ConceptsMap[unchanged].ConceptStep.Items[1].(*gauge.Step).Value, Equals, oldStep+"T")112}113func (s *MySuite) TestRefactoringGivesOnlySpecsThatAreRefactored(c *C) {114 oldStep := " first step"115 newStep := "second step"116 tokens := []*parser.Token{117 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},118 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},119 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3},120 }121 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")122 tokens = []*parser.Token{123 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 10},124 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 20},125 &parser.Token{Kind: gauge.StepKind, Value: newStep, LineNo: 30},126 }127 spec1, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")128 specs := append(make([]*gauge.Specification, 0), spec)129 specs = append(specs, spec1)130 agent, _ := getRefactorAgent(oldStep, newStep, nil)131 specRefactored, _ := agent.rephraseInSpecsAndConcepts(&specs, gauge.NewConceptDictionary())132 c.Assert(true, Equals, specRefactored[specs[0]])133 c.Assert(false, Equals, specRefactored[specs[1]])134}135func (s *MySuite) TestRefactoringGivesOnlyThoseConceptFilesWhichAreRefactored(c *C) {136 oldStep := "first step"137 newStep := "second step"138 unchanged := "unchanged"139 tokens := []*parser.Token{140 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},141 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 20},142 }143 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")144 agent, _ := getRefactorAgent(oldStep, newStep, nil)145 specs := append(make([]*gauge.Specification, 0), spec)146 dictionary := gauge.NewConceptDictionary()147 step1 := &gauge.Step{Value: oldStep + "sdsf", IsConcept: true}148 step2 := &gauge.Step{Value: unchanged, IsConcept: true, Items: []gauge.Item{&gauge.Step{Value: newStep, IsConcept: false}, &gauge.Step{Value: oldStep + "T", IsConcept: false}}}149 step3 := &gauge.Step{Value: "Concept value", IsConcept: true, Items: []gauge.Item{&gauge.Step{Value: oldStep, IsConcept: false}, &gauge.Step{Value: oldStep + "T", IsConcept: false}}}150 fileName := "file.cpt"151 dictionary.ConceptsMap[step1.Value] = &gauge.Concept{ConceptStep: step1, FileName: fileName}152 dictionary.ConceptsMap[step2.Value] = &gauge.Concept{ConceptStep: step2, FileName: fileName}153 dictionary.ConceptsMap[step3.Value] = &gauge.Concept{ConceptStep: step3, FileName: "e" + fileName}154 _, filesRefactored := agent.rephraseInSpecsAndConcepts(&specs, dictionary)155 c.Assert(filesRefactored[fileName], Equals, false)156 c.Assert(filesRefactored["e"+fileName], Equals, true)157}158func (s *MySuite) TestRenamingWhenNumberOfArgumentsAreSame(c *C) {159 oldStep := "first step {static} and {static}"160 oldStep1 := "first step <a> and <b>"161 newStep := "second step <a> and <b>"162 tokens := []*parser.Token{163 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},164 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},165 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address"}},166 }167 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")168 agent, _ := getRefactorAgent(oldStep1, newStep, nil)169 specs := append(make([]*gauge.Specification, 0), spec)170 dictionary := gauge.NewConceptDictionary()171 agent.rephraseInSpecsAndConcepts(&specs, dictionary)172 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {}")173 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "name")174 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "address")175}176func (s *MySuite) TestRenamingWhenArgumentsOrderIsChanged(c *C) {177 oldStep := "first step {static} and {static} and {static} and {static}"178 oldStep1 := "first step <a> and <b> and <c> and <d>"179 newStep := "second step <d> and <b> and <c> and <a>"180 tokens := []*parser.Token{181 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},182 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},183 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},184 }185 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")186 agent, _ := getRefactorAgent(oldStep1, newStep, nil)187 specs := append(make([]*gauge.Specification, 0), spec)188 dictionary := gauge.NewConceptDictionary()189 agent.rephraseInSpecsAndConcepts(&specs, dictionary)190 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {} and {}")191 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "id")192 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "address")193 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "number")194 c.Assert(specs[0].Scenarios[0].Steps[0].Args[3].Value, Equals, "name")195}196func (s *MySuite) TestCreateOrderGivesMapOfOldArgsAndNewArgs(c *C) {197 step1 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "a"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}, &gauge.StepArg{Name: "d"}}}198 step2 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "d"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}, &gauge.StepArg{Name: "a"}}}199 agent := &rephraseRefactorer{step1, step2, false, nil}200 orderMap := agent.createOrderOfArgs()201 c.Assert(orderMap[0], Equals, 3)202 c.Assert(orderMap[1], Equals, 1)203 c.Assert(orderMap[2], Equals, 2)204}205func (s *MySuite) TestCreateOrderGivesMapOfOldArgsAndNewWhenArgsAreAdded(c *C) {206 step1 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "a"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}, &gauge.StepArg{Name: "d"}}}207 step2 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "d"}, &gauge.StepArg{Name: "e"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}, &gauge.StepArg{Name: "a"}}}208 agent := &rephraseRefactorer{step1, step2, false, nil}209 orderMap := agent.createOrderOfArgs()210 c.Assert(orderMap[0], Equals, 3)211 c.Assert(orderMap[1], Equals, -1)212 c.Assert(orderMap[2], Equals, 1)213 c.Assert(orderMap[3], Equals, 2)214 c.Assert(orderMap[4], Equals, 0)215}216func (s *MySuite) TestCreateOrderGivesMapOfOldArgsAndNewWhenArgsAreRemoved(c *C) {217 step1 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "a"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}, &gauge.StepArg{Name: "d"}}}218 step2 := &gauge.Step{Args: []*gauge.StepArg{&gauge.StepArg{Name: "d"}, &gauge.StepArg{Name: "b"}, &gauge.StepArg{Name: "c"}}}219 agent := &rephraseRefactorer{step1, step2, false, nil}220 orderMap := agent.createOrderOfArgs()221 c.Assert(orderMap[0], Equals, 3)222 c.Assert(orderMap[1], Equals, 1)223 c.Assert(orderMap[2], Equals, 2)224}225func (s *MySuite) TestCreationOfOrderMapForStep(c *C) {226 agent, _ := getRefactorAgent("Say <greeting> to <name>", "Say <greeting> to <name> \"DD\"", nil)227 orderMap := agent.createOrderOfArgs()228 c.Assert(orderMap[0], Equals, 0)229 c.Assert(orderMap[1], Equals, 1)230 c.Assert(orderMap[2], Equals, -1)231}232func (s *MySuite) TestRenamingWhenArgumentsIsAddedAtLast(c *C) {233 oldStep := "first step {static} and {static} and {static}"234 oldStep1 := "first step <a> and <b> and <c>"235 newStep := "second step <a> and <b> and <c> and <d>"236 tokens := []*parser.Token{237 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},238 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},239 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number"}},240 }241 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")242 agent, _ := getRefactorAgent(oldStep1, newStep, nil)243 specs := append(make([]*gauge.Specification, 0), spec)244 dictionary := gauge.NewConceptDictionary()245 agent.rephraseInSpecsAndConcepts(&specs, dictionary)246 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {} and {}")247 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "name")248 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "address")249 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "number")250 c.Assert(specs[0].Scenarios[0].Steps[0].Args[3].Value, Equals, "d")251}252func (s *MySuite) TestRenamingWhenArgumentsIsAddedAtFirst(c *C) {253 oldStep := "first step {static} and {static} and {static}"254 oldStep1 := "first step <a> and <b> and <c>"255 newStep := "second step <d> and <a> and <b> and <c>"256 tokens := []*parser.Token{257 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},258 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},259 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number"}},260 }261 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")262 agent, _ := getRefactorAgent(oldStep1, newStep, nil)263 specs := append(make([]*gauge.Specification, 0), spec)264 dictionary := gauge.NewConceptDictionary()265 agent.rephraseInSpecsAndConcepts(&specs, dictionary)266 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {} and {}")267 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "d")268 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "name")269 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "address")270 c.Assert(specs[0].Scenarios[0].Steps[0].Args[3].Value, Equals, "number")271}272func (s *MySuite) TestRenamingWhenArgumentsIsAddedInMiddle(c *C) {273 oldStep := "first step {static} and {static} and {static}"274 oldStep1 := "first step <a> and <b> and <c>"275 newStep := "second step <a> and <d> and <b> and <c>"276 tokens := []*parser.Token{277 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},278 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},279 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number"}},280 }281 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")282 agent, _ := getRefactorAgent(oldStep1, newStep, nil)283 specs := append(make([]*gauge.Specification, 0), spec)284 dictionary := gauge.NewConceptDictionary()285 agent.rephraseInSpecsAndConcepts(&specs, dictionary)286 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {} and {}")287 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "name")288 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "d")289 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "address")290 c.Assert(specs[0].Scenarios[0].Steps[0].Args[3].Value, Equals, "number")291}292func (s *MySuite) TestRenamingWhenArgumentsIsRemovedFromLast(c *C) {293 oldStep := "first step {static} and {static} and {static} and {static}"294 oldStep1 := "first step <a> and <b> and <c> and <d>"295 newStep := "second step <a> and <b> and <c>"296 tokens := []*parser.Token{297 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},298 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},299 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},300 }301 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")302 agent, _ := getRefactorAgent(oldStep1, newStep, nil)303 specs := append(make([]*gauge.Specification, 0), spec)304 dictionary := gauge.NewConceptDictionary()305 agent.rephraseInSpecsAndConcepts(&specs, dictionary)306 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {}")307 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "name")308 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "address")309 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "number")310}311func (s *MySuite) TestRenamingWhenArgumentsIsRemovedFromBegining(c *C) {312 oldStep := "first step {static} and {static} and {static} and {static}"313 oldStep1 := "first step <a> and <b> and <c> and <d>"314 newStep := "second step <b> and <c> and <d>"315 tokens := []*parser.Token{316 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},317 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},318 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},319 }320 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")321 agent, _ := getRefactorAgent(oldStep1, newStep, nil)322 specs := append(make([]*gauge.Specification, 0), spec)323 dictionary := gauge.NewConceptDictionary()324 agent.rephraseInSpecsAndConcepts(&specs, dictionary)325 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {}")326 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "address")327 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "number")328 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "id")329}330func (s *MySuite) TestRenamingWhenArgumentsIsRemovedFromMiddle(c *C) {331 oldStep := "first step {static} and {static} and {static} and {static}"332 oldStep1 := "first step <a> and <b> and <c> and <d>"333 newStep := "second step <a> and <b> and <d>"334 tokens := []*parser.Token{335 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},336 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},337 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},338 }339 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")340 agent, _ := getRefactorAgent(oldStep1, newStep, nil)341 specs := append(make([]*gauge.Specification, 0), spec)342 dictionary := gauge.NewConceptDictionary()343 agent.rephraseInSpecsAndConcepts(&specs, dictionary)344 c.Assert(specs[0].Scenarios[0].Steps[0].Value, Equals, "second step {} and {} and {}")345 c.Assert(specs[0].Scenarios[0].Steps[0].Args[0].Value, Equals, "name")346 c.Assert(specs[0].Scenarios[0].Steps[0].Args[1].Value, Equals, "address")347 c.Assert(specs[0].Scenarios[0].Steps[0].Args[2].Value, Equals, "id")348}349func (s *MySuite) TestGenerateNewStepNameGivesLineTextWithActualParamNames(c *C) {350 args := []string{"name", "address", "id"}351 newStep := "second step <a> and <b> and <d>"352 orderMap := make(map[int]int)353 orderMap[0] = 1354 orderMap[1] = 2355 orderMap[2] = 0356 agent, _ := getRefactorAgent(newStep, newStep, nil)357 linetext := agent.generateNewStepName(args, orderMap)358 c.Assert(linetext, Equals, "second step <address> and <id> and <name>")359}360func (s *MySuite) TestGenerateNewStepNameWhenParametersAreAdded(c *C) {361 args := []string{"name", "address"}362 newStep := "changed step <a> and <b> and \"id\""363 orderMap := make(map[int]int)364 orderMap[0] = 1365 orderMap[1] = 0366 orderMap[2] = -1367 agent, _ := getRefactorAgent(newStep, newStep, nil)368 linetext := agent.generateNewStepName(args, orderMap)369 c.Assert(linetext, Equals, "changed step <address> and <name> and \"id\"")370}371func (s *MySuite) TestGenerateNewStepNameWhenParametersAreRemoved(c *C) {372 args := []string{"name", "address", "desc"}373 newStep := "changed step <b> and \"id\""374 orderMap := make(map[int]int)375 orderMap[0] = 1376 orderMap[1] = -1377 orderMap[2] = -1378 agent, _ := getRefactorAgent(newStep, newStep, nil)379 linetext := agent.generateNewStepName(args, orderMap)380 c.Assert(linetext, Equals, "changed step <address> and \"id\"")381}382func (s *MySuite) TestGenerateNewStepNameWhenParametersAreUnchanged(c *C) {383 args := []string{"a"}384 newStep := "make comment <a>"385 agent, _ := getRefactorAgent("Comment <a>", newStep, nil)386 linetext := agent.generateNewStepName(args, agent.createOrderOfArgs())387 c.Assert(linetext, Equals, "make comment <a>")388}389func (s *MySuite) TestRefactoringInContextStep(c *C) {390 oldStep := "first step {static} and {static} and {static} and {static}"391 oldStep1 := "first step <a> and <b> and <c> and <d>"392 newStep := "second step <d> and <b> and <c> and <a>"393 tokens := []*parser.Token{394 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},395 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},396 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},397 &parser.Token{Kind: gauge.StepKind, Value: oldStep + " sdf", LineNo: 3, Args: []string{"name", "address", "number", "id"}},398 }399 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")400 agent, _ := getRefactorAgent(oldStep1, newStep, nil)401 specs := append(make([]*gauge.Specification, 0), spec)402 dictionary := gauge.NewConceptDictionary()403 agent.rephraseInSpecsAndConcepts(&specs, dictionary)404 c.Assert(specs[0].Contexts[0].Value, Equals, "second step {} and {} and {} and {}")405 c.Assert(specs[0].Contexts[0].Args[0].Value, Equals, "id")406 c.Assert(specs[0].Contexts[0].Args[1].Value, Equals, "address")407 c.Assert(specs[0].Contexts[0].Args[2].Value, Equals, "number")408 c.Assert(specs[0].Contexts[0].Args[3].Value, Equals, "name")409}410func (s *MySuite) TestRefactoringInTearDownStep(c *C) {411 oldStep := "first step {static} and {static} and {static} and {static}"412 oldStep1 := "first step <a> and <b> and <c> and <d>"413 newStep := "second step <d> and <b> and <c> and <a>"414 tokens := []*parser.Token{415 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},416 &parser.Token{Kind: gauge.StepKind, Value: oldStep + "sdf", LineNo: 3, Args: []string{"name", "address", "number", "id"}},417 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading 1", LineNo: 2},418 &parser.Token{Kind: gauge.StepKind, Value: oldStep + " sdf", LineNo: 3, Args: []string{"name", "address", "number", "id"}},419 &parser.Token{Kind: gauge.TearDownKind, Value: "____", LineNo: 3},420 &parser.Token{Kind: gauge.StepKind, Value: oldStep, LineNo: 3, Args: []string{"name", "address", "number", "id"}},421 }422 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")423 agent, _ := getRefactorAgent(oldStep1, newStep, nil)424 specs := append(make([]*gauge.Specification, 0), spec)425 dictionary := gauge.NewConceptDictionary()426 agent.rephraseInSpecsAndConcepts(&specs, dictionary)427 c.Assert(specs[0].TearDownSteps[0].Value, Equals, "second step {} and {} and {} and {}")428 c.Assert(specs[0].TearDownSteps[0].Args[0].Value, Equals, "id")429 c.Assert(specs[0].TearDownSteps[0].Args[1].Value, Equals, "address")430 c.Assert(specs[0].TearDownSteps[0].Args[2].Value, Equals, "number")431 c.Assert(specs[0].TearDownSteps[0].Args[3].Value, Equals, "name")432}...

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2var _ = gauge.Step("Concept with <param1> and <param2>", func(param1, param2 string) {3 fmt.Println("Concept with " + param1 + " and " + param2)4})5import (6var _ = gauge.Step("Concept with <param1>", func(param1 string) {7 fmt.Println("Concept with " + param1)8})9import (10var _ = gauge.Step("Concept with <param1> and <param2>", func(param1, param2 string) {11 fmt.Println("Concept with " + param1 + " and " + param2)12})13import (14var _ = gauge.Step("Concept with <param1>", func(param1 string) {15 fmt.Println("Concept with " + param1)16})17import (18var _ = gauge.Step("Concept with <param1> and <param2>", func(param1, param2 string) {19 fmt.Println("Concept with " + param1 + " and " + param2)20})21import (22var _ = gauge.Step("Concept with <param1>", func(param1 string) {23 fmt.Println("Concept with " + param1)24})25import (26var _ = gauge.Step("Concept with <param1

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 conceptDictionary := gauge.NewConceptDictionary()4 fmt.Println(conceptDictionary)5}6{map[] [] []}7gauge.Step("Login as (.*) with password (.*)", func(user, password string) {...})8gauge.Step("Login as <user> with password <password>", func(user, password string, ctx *gauge.Context) {...})9gauge.Step("Login as <user> with password <password>", func(user, password string, ctx *gauge.Context) {10 ctx.Set("user", user)11 ctx.Set("password", password)12})13gauge.Step("Login as <user> with password <password>", func(user, password string, ctx *gauge.Context) {14 ctx.Scenario.Set("user", user)15 ctx.Scenario.Set("password", password)16})

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 gauge.NewConceptDictionary()4 fmt.Println("Hello, 世界")5}6import (7func main() {8 gauge.NewConceptDictionary()9 fmt.Println("Hello, 世界")10}11import (12func main() {13 gauge.NewConceptDictionary()14 fmt.Println("Hello, 世界")15}16import (17func main() {18 gauge.NewConceptDictionary()19 fmt.Println("Hello, 世界")20}21import (22func main() {23 gauge.NewConceptDictionary()24 fmt.Println("Hello, 世界")25}26import (27func main() {28 gauge.NewConceptDictionary()29 fmt.Println("Hello, 世界")30}31import (32func main() {33 gauge.NewConceptDictionary()34 fmt.Println("Hello, 世界")35}36import (37func main() {38 gauge.NewConceptDictionary()39 fmt.Println("Hello, 世界")40}41import (42func main() {43 gauge.NewConceptDictionary()44 fmt.Println("Hello, 世界")45}

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 conceptDictionary := gauge.NewConceptDictionary()4 conceptDictionary.AddConcept("Concept1", []*gauge.Step{&gauge.Step{Value: "Step1", LineNo: 1, ActualText: "Step1", ParameterizedStepValue: "Step1", Span: &gauge.Span{Start: 1, End: 1}}, &gauge.Step{Value: "Step2", LineNo: 2, ActualText: "Step2", ParameterizedStepValue: "Step2", Span: &gauge.Span{Start: 2, End: 2}}})5 conceptDictionary.AddConcept("Concept2", []*gauge.Step{&gauge.Step{Value: "Step3", LineNo: 3, ActualText: "Step3", ParameterizedStepValue: "Step3", Span: &gauge.Span{Start: 3, End: 3}}, &gauge.Step{Value: "Step4", LineNo: 4, ActualText: "Step4", ParameterizedStepValue: "Step4", Span: &gauge.Span{Start: 4, End: 4}}})6 conceptDictionary.AddConcept("Concept3", []*gauge.Step{&gauge.Step{Value: "Step5", LineNo: 5, ActualText: "Step5", ParameterizedStepValue: "Step5", Span: &gauge.Span{Start: 5, End: 5}}, &gauge.Step{Value: "Step6", LineNo: 6, ActualText: "Step6", ParameterizedStepValue: "Step6", Span: &gauge.Span{Start: 6, End: 6}}})7 conceptDictionary.AddConcept("Concept4", []*gauge.Step{&gauge.Step{Value: "Step7", LineNo: 7, ActualText: "Step7", ParameterizedStepValue: "Step7", Span: &gauge.Span{Start: 7, End: 7}}, &gauge.Step{Value: "Step8", LineNo: 8, ActualText: "Step8", ParameterizedStepValue: "Step8", Span: &gauge.Span{Start: 8, End: 8}}})

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World!")4}5import (6func main() {7 fmt.Println("Hello World!")8}9import (10func main() {11 fmt.Println("Hello World!")12}13import (14func main() {15 fmt.Println("Hello World!")16}17import (18func main() {19 fmt.Println("Hello World!")20}21import (22func main() {23 fmt.Println("Hello World!")24}25import (26func main() {27 fmt.Println("Hello World!")28}29import (30func main() {31 fmt.Println("Hello World!")32}33import (34func main() {35 fmt.Println("Hello World!")36}37import (38func main() {39 fmt.Println("Hello World

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4 dictionary := gauge.NewConceptDictionary()5 dictionary.AddConcept("say hello to {name}", []string{"hello {name}"})6}

Full Screen

Full Screen

NewConceptDictionary

Using AI Code Generation

copy

Full Screen

1import (2func helloWorld() {3 fmt.Println("Hello World!")4}5func helloName(name string) {6 fmt.Println("Hello", name)7}8func main() {9 gauge.NewConceptDictionary()10}11import (12func helloWorld() {13 fmt.Println("Hello World!")14}15func helloName(name string) {16 fmt.Println("Hello", name)17}18func main() {19 gauge.NewConceptDictionary()20}21import (22func helloWorld() {23 fmt.Println("Hello World!")24}25func helloName(name string) {26 fmt.Println("Hello", name)27}28func main() {29 gauge.NewConceptDictionary()30}31import (32func helloWorld() {33 fmt.Println("Hello World!")34}35func helloName(name string) {36 fmt.Println("Hello", name)37}38func main() {39 gauge.NewConceptDictionary()40}41import (42func helloWorld() {43 fmt.Println("Hello World!")44}45func helloName(name string) {46 fmt.Println("Hello", name)47}48func main() {49 gauge.NewConceptDictionary()50}51import (

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Top Programming Languages Helpful For Testers

There are many debates going on whether testers should know programming languages or not. Everyone has his own way of backing the statement. But when I went on a deep research into it, I figured out that no matter what, along with soft skills, testers must know some programming languages as well. Especially those that are popular in running automation tests.

Selenium C# Tutorial: Introduction

As per, Stack Overflow Annual Developer Survey 2019, C# is one of the most loved programming languages with 67% and is also deemed to be one of the most popular languages with 31% votes from all the respondents.

23 Node.js Best Practices For Automation Testing

If you are in the world of software development, you must be aware of Node.js. From Amazon to LinkedIn, a plethora of major websites use Node.js. Powered by JavaScript, Node.js can run on a server, and a majority of devs use it for enterprise applications. As they consider it a very respectable language due to the power it provides them to work with. And if you follow Node.js best practices, you can increase your application performance on a vast scale.

Cypress vs Selenium – Which Is Better ?

Selenium is one of the most prominent automation frameworks for functional testing and web app testing. Automation testers who use Selenium can run tests across different browser and platform combinations by leveraging an online Selenium Grid, you can learn more about what Is Selenium? Though Selenium is the go-to framework for test automation, Cypress – a relatively late entrant in the test automation game has been catching up at a breakneck pace.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful