How to use createSpecification method of parser Package

Best Gauge code snippet using parser.createSpecification

refactor_test.go

Source:refactor_test.go Github

copy

Full Screen

1// Copyright 2015 ThoughtWorks, Inc.2// This file is part of Gauge.3// Gauge is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7// Gauge is distributed in the hope that it will be useful,8// but WITHOUT ANY WARRANTY; without even the implied warranty of9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10// GNU General Public License for more details.11// You should have received a copy of the GNU General Public License12// along with Gauge. If not, see <http://www.gnu.org/licenses/>.13package refactor14import (15 "testing"16 "github.com/getgauge/gauge/gauge"17 "github.com/getgauge/gauge/parser"18 . "gopkg.in/check.v1"19)20func Test(t *testing.T) { TestingT(t) }21type MySuite struct{}22var _ = Suite(&MySuite{})23func (s *MySuite) TestRefactoringOfStepsWithNoArgs(c *C) {24 oldStep := "first step"25 newStep := "second step"26 tokens := []*parser.Token{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

formatter_test.go

Source:formatter_test.go Github

copy

Full Screen

1// Copyright 2015 ThoughtWorks, Inc.2// This file is part of Gauge.3// Gauge is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7// Gauge is distributed in the hope that it will be useful,8// but WITHOUT ANY WARRANTY; without even the implied warranty of9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10// GNU General Public License for more details.11// You should have received a copy of the GNU General Public License12// along with Gauge. If not, see <http://www.gnu.org/licenses/>.13package formatter14import (15 "testing"16 "github.com/getgauge/gauge/gauge"17 "github.com/getgauge/gauge/parser"18 . "gopkg.in/check.v1"19)20func Test(t *testing.T) { TestingT(t) }21type MySuite struct{}22var _ = Suite(&MySuite{})23func (s *MySuite) TestFormatSpecification(c *C) {24 tokens := []*parser.Token{25 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},26 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},27 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 3, LineText: "Example step"},28 &parser.Token{Kind: gauge.StepKind, Value: "Step with inline table", LineNo: 3, LineText: "Step with inline table "},29 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},30 &parser.Token{Kind: gauge.TableRow, Args: []string{"<1>", "foo"}},31 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},32 }33 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")34 formatted := FormatSpecification(spec)35 c.Assert(formatted, Equals,36 `Spec Heading37============38Scenario Heading39----------------40* Example step41* Step with inline table`+" "+`42 |id |name|43 |---|----|44 |<1>|foo |45 |2 |bar |46`)47}48func (s *MySuite) TestFormatTable(c *C) {49 cell1 := gauge.TableCell{"john", gauge.Static}50 cell2 := gauge.TableCell{"doe", gauge.Static}51 headers := []string{"name1", "name2"}52 cols := [][]gauge.TableCell{{cell1}, {cell2}}53 table := gauge.NewTable(headers, cols, 10)54 got := FormatTable(table)55 want := `56 |name1|name2|57 |-----|-----|58 |john |doe |59`60 c.Assert(got, Equals, want)61}62func (s *MySuite) TestFormatConcepts(c *C) {63 dictionary := gauge.NewConceptDictionary()64 step1 := &gauge.Step{Value: "sdsf", LineText: "sdsf", IsConcept: true, LineNo: 1, PreComments: []*gauge.Comment{&gauge.Comment{Value: "COMMENT", LineNo: 1}}}65 step2 := &gauge.Step{Value: "dsfdsfdsf", LineText: "dsfdsfdsf", IsConcept: true, LineNo: 2, Items: []gauge.Item{&gauge.Step{Value: "sfd", LineText: "sfd", IsConcept: false}, &gauge.Step{Value: "sdfsdf" + "T", LineText: "sdfsdf" + "T", IsConcept: false}}}66 dictionary.ConceptsMap[step1.Value] = &gauge.Concept{ConceptStep: step1, FileName: "file.cpt"}67 dictionary.ConceptsMap[step2.Value] = &gauge.Concept{ConceptStep: step2, FileName: "file.cpt"}68 formatted := FormatConcepts(dictionary)69 c.Assert(formatted["file.cpt"], Equals, `COMMENT70# sdsf71# dsfdsfdsf72* sdfsdfT73`)74}75func (s *MySuite) TestFormatSpecificationWithTags(c *C) {76 tokens := []*parser.Token{77 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},78 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag1", "tag2"}, LineNo: 2},79 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 3},80 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag3", "tag4"}, LineNo: 4},81 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 5, LineText: "Example step"},82 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading1", LineNo: 6},83 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag3", "tag4"}, LineNo: 7},84 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step"},85 }86 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")87 formatted := FormatSpecification(spec)88 c.Assert(formatted, Equals,89 `My Spec Heading90===============91tags: tag1, tag292Scenario Heading93----------------94tags: tag3, tag495* Example step96Scenario Heading197-----------------98tags: tag3, tag499* Example step100`)101}102func (s *MySuite) TestFormatSpecificationWithTeardownSteps(c *C) {103 tokens := []*parser.Token{104 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},105 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag1", "tag2"}, LineNo: 2},106 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 3},107 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag3", "tag4"}, LineNo: 4},108 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 5, LineText: "Example step"},109 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading1", LineNo: 6},110 &parser.Token{Kind: gauge.TagKind, Args: []string{"tag3", "tag4"}, LineNo: 7},111 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step"},112 &parser.Token{Kind: gauge.TearDownKind, Value: "____", LineNo: 9},113 &parser.Token{Kind: gauge.StepKind, Value: "Example step1", LineNo: 10, LineText: "Example step1"},114 &parser.Token{Kind: gauge.StepKind, Value: "Example step2", LineNo: 11, LineText: "Example step2"},115 }116 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")117 formatted := FormatSpecification(spec)118 c.Assert(formatted, Equals,119 `My Spec Heading120===============121tags: tag1, tag2122Scenario Heading123----------------124tags: tag3, tag4125* Example step126Scenario Heading1127-----------------128tags: tag3, tag4129* Example step130____131* Example step1132* Example step2133`)134}135func (s *MySuite) TestFormatStep(c *C) {136 step := &gauge.Step{Value: "my step with {}, {}, {} and {}", Args: []*gauge.StepArg{&gauge.StepArg{Value: "static \"foo\"", ArgType: gauge.Static},137 &gauge.StepArg{Value: "dynamic \"foo\"", ArgType: gauge.Dynamic},138 &gauge.StepArg{Name: "file:user\".txt", ArgType: gauge.SpecialString},139 &gauge.StepArg{Name: "table :hell\".csv", ArgType: gauge.SpecialTable}}}140 formatted := FormatStep(step)141 c.Assert(formatted, Equals, `* my step with "static \"foo\"", <dynamic \"foo\">, <file:user\".txt> and <table :hell\".csv>142`)143}144func (s *MySuite) TestFormattingWithTableAsAComment(c *C) {145 tokens := []*parser.Token{146 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},147 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 3},148 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}, LineText: " |id|name|"},149 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "foo"}, LineText: " |1|foo|"},150 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}, LineText: "|2|bar|"},151 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 5, LineText: "Example step"},152 }153 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")154 formatted := FormatSpecification(spec)155 c.Assert(formatted, Equals,156 `My Spec Heading157===============158Scenario Heading159----------------160 |id|name|161 |1|foo|162|2|bar|163* Example step164`)165}166func (s *MySuite) TestFormatSpecificationWithTableContainingDynamicParameters(c *C) {167 tokens := []*parser.Token{168 &parser.Token{Kind: gauge.SpecKind, Value: "Spec Heading", LineNo: 1},169 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "foo"}},170 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "f"}},171 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 2},172 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 3, LineText: "Example step"},173 &parser.Token{Kind: gauge.StepKind, Value: "Step with inline table", LineNo: 3, LineText: "Step with inline table "},174 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},175 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "<foo>"}},176 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},177 }178 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")179 formatted := FormatSpecification(spec)180 c.Assert(formatted, Equals,181 `Spec Heading182============183 |id|foo|184 |--|---|185 |1 |f |186Scenario Heading187----------------188* Example step189* Step with inline table `+`190 |id|name |191 |--|-----|192 |1 |<foo>|193 |2 |bar |194`)195}196func (s *MySuite) TestFormatShouldRetainNewlines(c *C) {197 tokens := []*parser.Token{198 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},199 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 2},200 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 3},201 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 4},202 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}, LineText: " |id|name|"},203 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "foo"}, LineText: " |1|foo|"},204 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}, LineText: "|2|bar|"},205 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step"},206 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},207 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "<foo>"}},208 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},209 }210 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")211 formatted := FormatSpecification(spec)212 c.Assert(formatted, Equals,213 `My Spec Heading214===============215Scenario Heading216----------------217 |id|name|218 |1|foo|219|2|bar|220* Example step `+`221 |id|name |222 |--|-----|223 |1 |<foo>|224 |2 |bar |225`)226}227func (s *MySuite) TestFormatShouldRetainNewlinesBetweenSteps(c *C) {228 tokens := []*parser.Token{229 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},230 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 4},231 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 6, LineText: "Example step", Suffix: "\n\n"},232 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 9, LineText: "Example step", Suffix: "\n\n"},233 }234 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")235 formatted := FormatSpecification(spec)236 c.Assert(formatted, Equals,237 `My Spec Heading238===============239Scenario Heading240----------------241* Example step242* Example step243`)244}245func (s *MySuite) TestFormatShouldStripDuplicateNewlinesBeforeInlineTable(c *C) {246 tokens := []*parser.Token{247 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},248 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 2},249 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 3},250 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 4},251 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}, LineText: " |id|name|"},252 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "foo"}, LineText: " |1|foo|"},253 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}, LineText: "|2|bar|"},254 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step\n\n"},255 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},256 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "<foo>"}},257 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},258 }259 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")260 formatted := FormatSpecification(spec)261 c.Assert(formatted, Equals,262 `My Spec Heading263===============264Scenario Heading265----------------266 |id|name|267 |1|foo|268|2|bar|269* Example step `+`270 |id|name |271 |--|-----|272 |1 |<foo>|273 |2 |bar |274`)275}276func (s *MySuite) TestFormatShouldStripDuplicateNewlinesBeforeInlineTableInTeardown(c *C) {277 tokens := []*parser.Token{278 &parser.Token{Kind: gauge.SpecKind, Value: "My Spec Heading", LineNo: 1},279 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 2},280 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 3},281 &parser.Token{Kind: gauge.ScenarioKind, Value: "Scenario Heading", LineNo: 4},282 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}, LineText: " |id|name|"},283 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "foo"}, LineText: " |1|foo|"},284 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}, LineText: "|2|bar|"},285 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step\n\n"},286 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},287 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "<foo>"}},288 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},289 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 10},290 &parser.Token{Kind: gauge.TearDownKind, Value: "____", LineNo: 9},291 &parser.Token{Kind: gauge.CommentKind, Value: "\n", LineNo: 10},292 &parser.Token{Kind: gauge.StepKind, Value: "Example step", LineNo: 8, LineText: "Example step\n\n\n"},293 &parser.Token{Kind: gauge.TableHeader, Args: []string{"id", "name"}},294 &parser.Token{Kind: gauge.TableRow, Args: []string{"1", "<foo>"}},295 &parser.Token{Kind: gauge.TableRow, Args: []string{"2", "bar"}},296 }297 spec, _ := new(parser.SpecParser).CreateSpecification(tokens, gauge.NewConceptDictionary(), "")298 formatted := FormatSpecification(spec)299 c.Assert(formatted, Equals,300 `My Spec Heading301===============302Scenario Heading303----------------304 |id|name|305 |1|foo|306|2|bar|307* Example step `+`308 |id|name |309 |--|-----|310 |1 |<foo>|311 |2 |bar |312____313* Example step `+`314 |id|name |315 |--|-----|316 |1 |<foo>|317 |2 |bar |318`)319}320func (s *MySuite) TestFormatShouldNotAddExtraNewLinesBeforeDataTable(c *C) {321 spec, _ := new(parser.SpecParser).Parse(`Specification Heading322=====================323 |Word |Vowel Count|324 |------|-----------|325 |Gauge |3 |326 |Mingle|2 |327 |Snap |1 |328 |GoCD |1 |329 |Rhythm|0 |330`, gauge.NewConceptDictionary(), "")331 formatted := FormatSpecification(spec)332 c.Assert(formatted, Equals,333 `Specification Heading334=====================335 |Word |Vowel Count|336 |------|-----------|337 |Gauge |3 |338 |Mingle|2 |339 |Snap |1 |340 |GoCD |1 |341 |Rhythm|0 |342`)343}...

Full Screen

Full Screen

createSpecification

Using AI Code Generation

copy

Full Screen

1var parser = new Parser();2var specification = parser.createSpecification("1.go");3var parser = new Parser();4var specification = parser.createSpecification("2.go");5var parser = new Parser();6var specification = parser.createSpecification("3.go");7var parser = new Parser();8var specification = parser.createSpecification("4.go");9var parser = new Parser();10var specification = parser.createSpecification("5.go");11var parser = new Parser();12var specification = parser.createSpecification("6.go");13var parser = new Parser();14var specification = parser.createSpecification("7.go");15var parser = new Parser();16var specification = parser.createSpecification("8.go");17var parser = new Parser();18var specification = parser.createSpecification("9.go");19var parser = new Parser();20var specification = parser.createSpecification("10.go");21var parser = new Parser();22var specification = parser.createSpecification("11.go");23var parser = new Parser();24var specification = parser.createSpecification("12.go");25var parser = new Parser();26var specification = parser.createSpecification("13.go");27var parser = new Parser();28var specification = parser.createSpecification("14.go");29var parser = new Parser();30var specification = parser.createSpecification("15.go");

Full Screen

Full Screen

createSpecification

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 p := parser{}4 p.createSpecification("name", "string")5 p.createSpecification("age", "int")6 p.createSpecification("height", "float")7 p.createSpecification("married", "bool")8}9import "fmt"10func main() {11 p := parser{}12 p.createSpecification("name", "string")13 p.createSpecification("age", "int")14 p.createSpecification("height", "float")15 p.createSpecification("married", "bool")16}17import "fmt"18func main() {19 p := parser{}20 p.createSpecification("name", "string")21 p.createSpecification("age", "int")22 p.createSpecification("height", "float")23 p.createSpecification("married", "bool")24}25import "fmt"26func main() {27 p := parser{}28 p.createSpecification("name", "string")29 p.createSpecification("age", "int")30 p.createSpecification("height", "float")31 p.createSpecification("married", "bool")32}33import "fmt"34func main() {35 p := parser{}36 p.createSpecification("name", "string")37 p.createSpecification("age", "int")38 p.createSpecification("height", "float")39 p.createSpecification("married", "bool")40}41import "fmt"42func main() {43 p := parser{}44 p.createSpecification("name", "string")45 p.createSpecification("age", "int")46 p.createSpecification("height", "float")47 p.createSpecification("married", "bool")48}49import "fmt"50func main() {51 p := parser{}52 p.createSpecification("name", "string")53 p.createSpecification("age", "int")54 p.createSpecification("height", "float")

Full Screen

Full Screen

createSpecification

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Enter the specification")4 fmt.Scanf("%s", &specification)5 parser.CreateSpecification(specification)6}7import (8func main() {9 fmt.Println("Enter the specification")10 fmt.Scanf("%s", &specification)11 parser.CreateSpecification(specification)12}13import (14func main() {15 fmt.Println("Enter the specification")16 fmt.Scanf("%s", &specification)17 parser.CreateSpecification(specification)18}19import (20func main() {21 fmt.Println("Enter the specification")22 fmt.Scanf("%s", &specification)23 parser.CreateSpecification(specification)24}25import (26func main() {27 fmt.Println("Enter the specification")28 fmt.Scanf("%s", &specification)29 parser.CreateSpecification(specification)30}31import (32func main() {33 fmt.Println("Enter the specification")34 fmt.Scanf("%s", &specification)35 parser.CreateSpecification(specification)36}37import (38func main() {39 fmt.Println("Enter the specification")40 fmt.Scanf("%s", &specification)41 parser.CreateSpecification(specification)42}43import (44func main() {45 fmt.Println("Enter the specification")46 fmt.Scanf("%s", &specification)47 parser.CreateSpecification(specification)48}

Full Screen

Full Screen

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