gpt4 book ai didi

testing - NUnit - 同名的多个属性?链接到要求

转载 作者:行者123 更新时间:2023-11-28 19:59:17 24 4
gpt4 key购买 nike

我将我们所有的系统测试链接到测试用例和我们的需求。每个需求都有一个 ID。每个测试用例/系统测试都会测试各种需求。每个代码模块都链接到多个需求。

我正在努力寻找将每个系统测试与其驾驶要求联系起来的最佳方法。

我希望做这样的事情:

    [NUnit.Framework.Property("Release", "6.0.0")]
[NUnit.Framework.Property("Requirement", "FR50082")]
[NUnit.Framework.Property("Requirement", "FR50084")]
[NUnit.Framework.Property("Requirement", "FR50085")]
[TestCase(....)]
public void TestSomething(string a, string b...)

但是,这会失败,因为 Property 是键值对。系统不允许我拥有多个具有相同 key 的属性。

我想要这样做的原因是,如果模块更改触及这些要求,则能够测试我们系统中的特定要求。

我们不必在每次构建时都运行 1,000 多个系统测试,这样我们就可以根据对代码所做的更改来确定要测试的内容。

一些系统测试运行时间超过 5 分钟(企业医疗保健系统),因此“只运行所有测试”不是一个可行的解决方案。我们这样做,但只是在通过我们的环境进行推广之前。

想法?

最佳答案

您是否考虑过 custom property attributeNUnit.Framework.Property 派生?

根据 LINQPad 4 判断,类似下面的内容可能对您有用“查询”,语言设置为 C# 程序 并添加了对 nunit.framework.dll(版本 2.4.8)的引用:

// main method to exercise a our PoC test case
void Main()
{
TestSomething("a", "b");
}

// our PoC custom property attribute
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public class RequirementsAttribute : NUnit.Framework.PropertyAttribute
{
public RequirementsAttribute(string[] requirements)
: base(requirements)
{
}
}

// a test case using our custom property attribute to relate it to multiple requirements
[Requirements(new string[] { "FR50082", "FR50084" })]
[TestCase("PoCTest")]
public void TestSomething(string a, string b)
{
// blah, blah, blah

Assert.AreNotEqual(a, b);
}

关于testing - NUnit - 同名的多个属性?链接到要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22187229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com