How to use specialStringArg method of parser Package

Best Gauge code snippet using parser.specialStringArg

parse_test.go

Source:parse_test.go Github

copy

Full Screen

...88	c.Assert(stepValue.StepValue, Equals, "simple step with {} and {}")89	c.Assert(stepValue.ParameterizedStepValue, Equals, "simple step with <hello> and <desc>")90}91func (s *MySuite) TestCreateStepValueFromStepWithSpecialParams(c *C) {92	step := &gauge.Step{Value: "a step with {}, {} and {}", Args: []*gauge.StepArg{specialTableArg("hello"), specialStringArg("file:user.txt"), tableArgument()}}93	stepValue := CreateStepValue(step)94	args := stepValue.Args95	c.Assert(len(args), Equals, 3)96	c.Assert(args[0], Equals, "hello")97	c.Assert(args[1], Equals, "file:user.txt")98	c.Assert(args[2], Equals, "table")99	c.Assert(stepValue.StepValue, Equals, "a step with {}, {} and {}")100	c.Assert(stepValue.ParameterizedStepValue, Equals, "a step with <hello>, <file:user.txt> and <table>")101}102func (s *MySuite) TestAddSpecsToMapPopulatesScenarioInExistingSpec(c *C) {103	specsMap := make(map[string]*gauge.Specification)104	scenario1 := &gauge.Scenario{Heading: &gauge.Heading{Value: "scenario1"}}105	scenario2 := &gauge.Scenario{Heading: &gauge.Heading{Value: "scenario2"}}106	heading := &gauge.Heading{Value: "spec heading"}107	specName := "foo.spec"108	spec1 := &gauge.Specification{Heading: heading, FileName: specName, Scenarios: []*gauge.Scenario{scenario1}, Items: []gauge.Item{heading, scenario1}}109	spec2 := &gauge.Specification{Heading: heading, FileName: specName, Scenarios: []*gauge.Scenario{scenario2}, Items: []gauge.Item{heading, scenario2}}110	specsMap[specName] = spec1111	addSpecsToMap([]*gauge.Specification{spec2}, specsMap)112	c.Assert(len(specsMap), Equals, 1)113	c.Assert(len(specsMap[specName].Scenarios), Equals, 2)114	c.Assert(len(specsMap[specName].Items), Equals, 3)115}116func (s *MySuite) TestSpecsFormArgsForMultipleIndexedArgsForOneSpec(c *C) {117	specs, _ := parseSpecsInDirs(gauge.NewConceptDictionary(), []string{filepath.Join("testdata", "sample.spec:3"), filepath.Join("testdata", "sample.spec:6")}, gauge.NewBuildErrors())118	c.Assert(len(specs), Equals, 1)119	c.Assert(len(specs[0].Scenarios), Equals, 2)120}121func (s *MySuite) TestToCheckIfItsIndexedSpec(c *C) {122	c.Assert(isIndexedSpec("specs/hello_world:as"), Equals, false)123	c.Assert(isIndexedSpec("specs/hello_world.spec:0"), Equals, true)124	c.Assert(isIndexedSpec("specs/hello_world.spec:78809"), Equals, true)125	c.Assert(isIndexedSpec("specs/hello_world.spec:09"), Equals, true)126	c.Assert(isIndexedSpec("specs/hello_world.spec:09sa"), Equals, false)127	c.Assert(isIndexedSpec("specs/hello_world.spec:09090"), Equals, true)128	c.Assert(isIndexedSpec("specs/hello_world.spec"), Equals, false)129	c.Assert(isIndexedSpec("specs/hello_world.spec:"), Equals, false)130	c.Assert(isIndexedSpec("specs/hello_world.md"), Equals, false)131}132func (s *MySuite) TestToObtainIndexedSpecName(c *C) {133	specName, scenarioNum := getIndexedSpecName("specs/hello_world.spec:67")134	c.Assert(specName, Equals, "specs/hello_world.spec")135	c.Assert(scenarioNum, Equals, 67)136}137func (s *MySuite) TestToObtainIndexedSpecName1(c *C) {138	specName, scenarioNum := getIndexedSpecName("hello_world.spec:67342")139	c.Assert(specName, Equals, "hello_world.spec")140	c.Assert(scenarioNum, Equals, 67342)141}142func (s *MySuite) TestGetIndex(c *C) {143	c.Assert(getIndex("hello.spec:67"), Equals, 10)144	c.Assert(getIndex("specs/hello.spec:67"), Equals, 16)145	c.Assert(getIndex("specs\\hello.spec:67"), Equals, 16)146	c.Assert(getIndex(":67"), Equals, 0)147	c.Assert(getIndex(""), Equals, 0)148	c.Assert(getIndex("foo"), Equals, 0)149	c.Assert(getIndex(":"), Equals, 0)150	c.Assert(getIndex("f:7a.spec:9"), Equals, 9)151}152func staticArg(val string) *gauge.StepArg {153	return &gauge.StepArg{ArgType: gauge.Static, Value: val}154}155func dynamicArg(val string) *gauge.StepArg {156	return &gauge.StepArg{ArgType: gauge.Dynamic, Value: val}157}158func tableArgument() *gauge.StepArg {159	return &gauge.StepArg{ArgType: gauge.TableArg}160}161func specialTableArg(val string) *gauge.StepArg {162	return &gauge.StepArg{ArgType: gauge.SpecialTable, Name: val}163}164func specialStringArg(val string) *gauge.StepArg {165	return &gauge.StepArg{ArgType: gauge.SpecialString, Name: val}166}...

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