关于使用SpecFlow框架进行封装,我有以下问题,目标是在方法2中封装方法1,下面是下面的特性/场景以及生成的步骤,我相信我需要使用string.format。无论如何,请建议如何封装方法1到方法2中给出的现有的。
首先,请看情景。
Scenario Outline: Compare XYZ data against the given templates
Given I have located the XYZ file from <xyzfilelocation>
Examples:
| xyzfilelocation |
| Tests\Meebu\Doggg\Cat\xyz\Yhyh800\Yhyh800_TheId_1234567.FirstOne.xml |
| Tests\Meebu\Doggg\Cat\xyz\Yhyh800\Yhyh800_TheId_7654321.SecondTwo.xml|第二,查看生成的步骤。
//Method 1
[Given(@"I have located the XYZ file from (.*)")]
public void GivenIHaveLocatedTheXYZFileFromLocation(string xyzfilelocation)
{
string file = new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName + "\\" + xyzfilelocation;
_context.ActualXYZ = new XmlDocument();
_context.ActualXYZ.Load(file);
}//方法2,我想在这里封装上面的方法,我试着在下面做,这是正确的方法吗?我相信我需要做string.format,请告知/这个方法有用吗?它是封装吗?
[When(@"I compare XYZ file (.*)")]
public void WhenICompareXYZFile(string xyzfilelocation)
{
//Calling the method Given I have located the XYZ file from <xyzfilelocation>
Given(string.Format("I have located the XYZ file from {0}", xyzfilelocation));
}发布于 2018-09-20 09:50:04
您可以像在标准类中那样调用该方法:GivenIHaveLocatedTheXYZFileFromLocation(string.Format("I have located the XYZ file from {0}", xyzfilelocation));
https://stackoverflow.com/questions/52421278
复制相似问题