我正在将我们所有的系统测试链接到测试用例和需求。每个需求都有一个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是一个键值对。系统不允许我使用相同的键来拥有多个属性。

我希望这样做的原因是,如果模块发生更改而满足这些需求,则能够测试我们系统中的特定需求。

不必在每个构建上运行超过1,000个系统测试,而是允许我们根据对代码所做的更改来确定要测试的对象。

有些系统测试需要运行5分钟以上(企业医疗系统),因此“仅运行所有这些”并不是可行的解决方案。我们这样做,但前提是在通过我们的环境进行推广之前。

有什么想法吗?

最佳答案

您是否考虑过从NUnit.Framework.Property派生的custom property attribute

通过将语言设置为C#程序并添加对nunit.framework.dll(版本2.4.8)的引用的LINQPad 4“查询”来判断,以下内容似乎对您可能有用:

// 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);
}

10-07 19:19
查看更多