当我在一行中提供示例时,它可以正常工作。 当我提供多行示例时,我得到了绑定参数异常。如果我在一行中提供所有示例,则不易阅读。
Feature: ConversionUnencrypted Pdf-Pdf
@mytag
Scenario Outline: ConversionUnencrypted Pdf-Pdf
Given I get Inputs Folder and list of Files <inputFolder> then <getInputTokens>
Given I get '<outputDirectory>'
Given I get directory to save Images '<ImagesOutputDirectory>'
Examples:
| inputFolder | getInputTokens | outputDirectory | ImagesOutputDirectory |
| D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Inputs\2files | Input1.pdf,Input2.pdf | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files |
Given I set saving Mode <ConversionMode>
Given I convert pdf using Conversion
Given I convert to Image '<convertToFile>'
Then I compare Images '<getActualImagePath>' and '<getExpectedImagePath>' and '<pageCount>'
| ConversionMode | convertToFile | getActualImagePath | getExpectedImagePath | pageCount |
| ConvertToSingleFile | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Expected\2files | 82 |
如果示例如下所示正常工作:
Examples:
| inputFolder | getInputTokens | outputDirectory | ImagesOutputDirectory | ConversionMode | convertToFile | getActualImagePath | getExpectedImagePath | pageCount |
| D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Inputs\2files | Input1.pdf,Input2.pdf | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files\ | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files\| ConvertToSingleFile | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files\ | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files |D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Expected\2files | 82 |
答案 0 :(得分:3)
您的第一个场景存在一些问题。您已将步骤与示例混合在一起。这些步骤必须在场景大纲中,它们不能在示例中。
鉴于此,如果您使用大纲中的步骤重新编写场景,那么它将如下所示:
Feature: ConversionUnencrypted Pdf-Pdf
@mytag
Scenario Outline: ConversionUnencrypted Pdf-Pdf
Given I get Inputs Folder and list of Files <inputFolder> then <getInputTokens>
Given I get '<outputDirectory>'
Given I get directory to save Images '<ImagesOutputDirectory>'
Given I set saving Mode <ConversionMode>
Given I convert pdf using Conversion
Given I convert to Image '<convertToFile>'
Then I compare Images '<getActualImagePath>' and '<getExpectedImagePath>' and '<pageCount>'
Examples:
| inputFolder | getInputTokens | outputDirectory | ImagesOutputDirectory |
| D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Inputs\2files | Input1.pdf,Input2.pdf | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files |
| ConversionMode | convertToFile | getActualImagePath | getExpectedImagePath | pageCount |
| ConvertToSingleFile | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\AfterConvertingToPdf\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Actual\2files | D:\SVN_Projects\XDoc.Net\SpecFlow\Conversion\ConvertToPdf\Expected\2files | 82 |
现在更明显的原因是你不能在不同的行上有两组示例,因为看起来inputFolder
的值为ConversionMode
,而实际上ConversionMode
是标题。
这里的主要问题是您的示例中有完整的文件路径。这是一个实现细节,恕我直言,删除这些路径并使用monikers会更好。毕竟那些完整的文件路径不能在你的任何机器上工作,而不是在构建服务器上。我会考虑像这样重写它们:
Examples:
| inputFolder | getInputTokens | outputDirectory | ImagesOutputDirectory | ConversionMode | convertToFile | getActualImagePath | getExpectedImagePath | pageCount |
| 2files | Input1.pdf,Input2.pdf | 2files | 2files | ConvertToSingleFile | 2files | 2files | 2files | 82 |
虽然现在它有很多重复的信息,现在已经减少了,所以你的整个场景可以像这样重写
Feature: ConversionUnencrypted Pdf-Pdf
@mytag
Scenario Outline: ConversionUnencrypted Pdf-Pdf
Given I am processing files in the subdirectory <workingFolder> of the input folder then <getInputTokens>
And I save file to the subdirectory <workingFolder> of the output folder
And I save Images to the subdirectory <workingFolder> of the images folder
And I set saving Mode <ConversionMode>
And I convert pdf using Conversion
And I convert to Image the files in the subdirectory <workingFolder> of the output folder
When I compare Images of page '<pageCount>' in the subdirectory <workingFolder> of the actual image folder and subdirectory <workingFolder> of the expected image folder
Then the images should be the same
Examples:
| workingFolder | getInputTokens | ConversionMode | pageCount |
| 2files | Input1.pdf,Input2.pdf | ConvertToSingleFile | 82 |
然后您可以根据项目创建基础文件夹,并将其作为测试版本的一部分进行部署,也可以保留在配置中。