NUnit - 多个同名属性?链接到需求 [英] NUnit - Multiple properties of the same name? Linking to requirements

查看:39
本文介绍了NUnit - 多个同名属性?链接到需求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm linking all our our System Tests to test cases and to our Requirements. Every requirement has an ID. Every Test Case / System Tests tests a variety of requirements. Every module of code links to multiple requirements.

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

I'm trying to find the best way to link every system test to its driving requirements.

我希望做这样的事情:

    [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...)

然而,这会中断,因为属性是一个键值对.系统不允许我拥有多个属性相同的密钥.

However, that will break because Property is a Key-Value pair. The system will not allow me to have multiple Properties with the same key.

我希望这样做的原因是,如果某个模块发生更改而触及这些要求,则能够测试我们系统中的特定要求.

The reason I'm wanting this is to be able to test specific requirements in our system if a module changes that touches these requirements.

无需在每次构建时运行 1,000 多个系统测试,这将使我们能够根据对代码所做的更改来确定要测试的内容.

Rather than run over 1,000 system tests on every build, this would allow us to target what to test based on changes done to our code.

某些系统测试运行时间超过 5 分钟(企业医疗保健系统),因此全部运行"不是可行的解决方案.我们这样做,但仅限于通过我们的环境进行推广之前.

Some system tests run upwards of 5 minutes (Enterprise healthcare system), so "Just run all of them" isn't a viable solution. We do that, but only before promoting through our environments.

想法?

推荐答案

您是否考虑过 自定义属性属性 派生自NUnit.Framework.Property?

Have you considered a custom property attribute derived from NUnit.Framework.Property?

通过 LINQPad 4 "query" with Language 判断,类似以下内容似乎对您有用设置为 C# Program 并添加对 nunit.framework.dll(版本 2.4.8)的引用:

Something like the following seems like it might work for you judging by a LINQPad 4 "query" with Language set to C# Program and a reference to nunit.framework.dll (version 2.4.8) added:

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

这篇关于NUnit - 多个同名属性?链接到需求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆