Best Gauge code snippet using parser.treatArgAsDynamic
specparser.go
Source:specparser.go
...592 resolvedArgValue, err := newSpecialTypeResolver().resolve(argValue)593 if err != nil {594 switch err.(type) {595 case invalidSpecialParamError:596 return treatArgAsDynamic(argValue, token, lookup, fileName)597 default:598 return nil, &ParseResult{ParseErrors: []ParseError{ParseError{FileName: fileName, LineNo: token.LineNo, Message: fmt.Sprintf("Dynamic parameter <%s> could not be resolved", argValue), LineText: token.LineText}}}599 }600 }601 return resolvedArgValue, nil602 } else if typeOfArg == "static" {603 return &gauge.StepArg{ArgType: gauge.Static, Value: argValue}, nil604 } else {605 return validateDynamicArg(argValue, token, lookup, fileName)606 }607}608func treatArgAsDynamic(argValue string, token *Token, lookup *gauge.ArgLookup, fileName string) (*gauge.StepArg, *ParseResult) {609 parseRes := &ParseResult{Warnings: []*Warning{&Warning{FileName: fileName, LineNo: token.LineNo, Message: fmt.Sprintf("Could not resolve special param type <%s>. Treating it as dynamic param.", argValue)}}}610 stepArg, result := validateDynamicArg(argValue, token, lookup, fileName)611 if result != nil {612 if len(result.ParseErrors) > 0 {613 parseRes.ParseErrors = result.ParseErrors614 }615 if result.Warnings != nil {616 for _, warn := range result.Warnings {617 parseRes.Warnings = append(parseRes.Warnings, warn)618 }619 }620 }621 return stepArg, parseRes622}...
stepParser.go
Source:stepParser.go
...188 resolvedArgValue, err := newSpecialTypeResolver().resolve(argValue)189 if err != nil {190 switch err.(type) {191 case invalidSpecialParamError:192 return treatArgAsDynamic(argValue, token, lookup, fileName)193 default:194 return &gauge.StepArg{ArgType: gauge.Dynamic, Value: argValue, Name: argValue}, &ParseResult{ParseErrors: []ParseError{ParseError{FileName: fileName, LineNo: token.LineNo, Message: fmt.Sprintf("Dynamic parameter <%s> could not be resolved", argValue), LineText: token.LineText}}}195 }196 }197 return resolvedArgValue, nil198 } else if typeOfArg == "static" {199 return &gauge.StepArg{ArgType: gauge.Static, Value: argValue}, nil200 } else {201 return validateDynamicArg(argValue, token, lookup, fileName)202 }203}204func treatArgAsDynamic(argValue string, token *Token, lookup *gauge.ArgLookup, fileName string) (*gauge.StepArg, *ParseResult) {205 parseRes := &ParseResult{Warnings: []*Warning{&Warning{FileName: fileName, LineNo: token.LineNo, Message: fmt.Sprintf("Could not resolve special param type <%s>. Treating it as dynamic param.", argValue)}}}206 stepArg, result := validateDynamicArg(argValue, token, lookup, fileName)207 if result != nil {208 if len(result.ParseErrors) > 0 {209 parseRes.ParseErrors = result.ParseErrors210 }211 if result.Warnings != nil {212 for _, warn := range result.Warnings {213 parseRes.Warnings = append(parseRes.Warnings, warn)214 }215 }216 }217 return stepArg, parseRes218}...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!