首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将方法1封装到方法2?

如何将方法1封装到方法2?
EN

Stack Overflow用户
提问于 2018-09-20 08:59:05
回答 1查看 41关注 0票数 1

关于使用SpecFlow框架进行封装,我有以下问题,目标是在方法2中封装方法1,下面是下面的特性/场景以及生成的步骤,我相信我需要使用string.format。无论如何,请建议如何封装方法1到方法2中给出的现有的。

首先,请看情景。

代码语言:javascript
复制
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|

第二,查看生成的步骤。

代码语言:javascript
复制
//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,请告知/这个方法有用吗?它是封装吗?

代码语言:javascript
复制
[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));
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-20 09:50:04

您可以像在标准类中那样调用该方法:GivenIHaveLocatedTheXYZFileFromLocation(string.Format("I have located the XYZ file from {0}", xyzfilelocation));

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52421278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档