c# - SpecFlow Ambiguity in bindings -
i'm working spec-flow quite days. facing "multiple matching found.navigating first match", while debugging can solved, when i'm running entire solution failing because of ambiguity in bindings. i'm running around 4 c sharp class files in single project
feature: conversionunencrypted pdf-pdf @mytag scenario outline: conversionunencrypted pdf-pdf given inputs folder , list of files <inputfolder> <getinputtokens>(multiple bindings line) given <outputdirectory> given set saving mode <conversionmode> given convert pdf using conversion given convert image <converttofile> compare images <getactualimagepath> , <getexpectedimagepath> , <pagecount> and step definitions:
**binding multiple steps below binding:** first binding:
[given(@"i inputs folder , list of files (.*) (.*)")] public void givenigetinputsfolderandlistoffilesthen(string getinputfolder, string getinputtokens) { --logic-- } second binding:
[given(@"i (.*)")] public void giveniget(string getoutputdirectory) { --logic-- } second binding modified to:
given set outputdirectory of pdf <outputdirectory> [given] public void given_i_set_outputdirectory_of_pdf_p0(string p0) { --logic-- } this 1 not helping me either. have tried regex still not resolve issue. there ambiguity in above mentioned 2 bindings. not in 1 feature observed other features file too. how can solved each line matches 1 binding ?
as @perfectionist has pointed out problem regexes. 1 consuming of chars both. try instead:
feature: conversionunencrypted pdf-pdf @mytag scenario outline: conversionunencrypted pdf-pdf given inputs folder , list of files '<inputfolder>' '<getinputtokens>' given '<outputdirectory>' ... and step definitions:
[given(@"i inputs folder , list of files '([^']*)' '([^']*)'")] public void givenigetinputsfolderandlistoffilesthen(string getinputfolder, string getinputtokens) { } [given(@"i '([^']*)'")] public void giveniget(string getoutputdirectory) { --logic-- } this regex match when input doesn't contain ' character prevent second method being greedy when consuming input , matching longer method.
as general rule prefer wrap string characters in single quotes above in scenario, makes issues easier mitigate
obviously above work if inputs '<inputfolder>','<getinputtokens>' , <outputfolder> not contain ' characters. if may need more complicated regex
Comments
Post a Comment