NUnit 测试用例生成:如何创建子文件夹(层次结构)?
我正在根据文件名生成 NUnit 测试用例。
该目录如下所示:
Customer
CustomerTestCase1.xml
CustomerTestCase2.xml
Account
AccountTestCase1.xml
AccountTestCase2.xml
我正在使用 TestCaseSource:
string[] list = Directory.GetFiles(path, "*", SearchOption.AllDirectories)
foreach (string file in list)
{
yield return new TestCaseData(file)
}
如何将层次结构引入生成的测试用例?我需要根据文件夹结构将它们组织成组,因此我可以勾选“帐户”,然后将选择所有帐户测试用例。
I am generating NUnit testcases based on the file names.
The directory looks like this:
Customer
CustomerTestCase1.xml
CustomerTestCase2.xml
Account
AccountTestCase1.xml
AccountTestCase2.xml
I am using TestCaseSource:
string[] list = Directory.GetFiles(path, "*", SearchOption.AllDirectories)
foreach (string file in list)
{
yield return new TestCaseData(file)
}
How do I introduce hierarchy into the generated testcases? I need them to be organized in groups according to folder structure, so I could tick "Account" and all the account testcases would be selected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Charlie Poole @ NUnit-讨论
Hi Andrey,
如果该结构是动态的,那么您无能为力。然而,
如果结构没有改变,那么你可以简单地编写多个
固定装置,并进行从不同来源获取数据的测试。
所以你可能有一个客户固定装置,从某些地方提取测试数据
特定的一个或多个源,以及提取其数据的帐户固定装置
来自其他来源。
将这些灯具的通用代码放入基类中,以便
你不必重复这个逻辑。事实上,应该很容易
直接从您必须使用基类的内容进行重构
然后为您想要的测试创建单独的叶类
分别选择。
查理
http://groups.google.com/group/nunit-discuss/ browser_thread/thread/543102e801511c41
Charlie Poole @ NUnit-Discuss
Hi Andrey,
If that structure is dynamic, then there is little you can do. However,
if the structure does not change, then you can simply code multiple
fixtures, with tests that take data from different sources.
So you might have a Customer fixture, pulling test data from some
particular source or sources, and an Account fixture pulling its data
from other sources.
Put the common code for these fixtures into a base class so that
you don't have to repeat the logic. In fact, it should be easy to
refactor directly from what you have to use of a base class and
then to create separate leaf classes for the tests you want to
select separately.
Charlie
http://groups.google.com/group/nunit-discuss/browse_thread/thread/543102e801511c41