在 DUnitX 中一次运行所有测试用例

时间:2020-12-23 21:28:01

标签: delphi dunitx

我有几个测试用例的测试,例如:

    [Test]
    [TestCase('Case1', '1')]
    [TestCase('Case2', '2')]
    [TestCase('Case3', '3')]
    procedure RunTest(const aParam: integer);

我可以单独运行每个测试用例,在参数中包含测试用例名称,例如 -rMyUnit.TMyTestClass.RunTest.Case1

我的问题是:如何一次运行所有测试用例,比如-rMyUnit.TMyTestClass.RunTest。*

我试过没有测试用例名称,但没有运气,它根本找不到测试。

1 个答案:

答案 0 :(得分:1)

根据 DUnitX 2015 的代码,这是不可能的

一种解决方法是为所有一个测试指定相同的测试用例名称

unit rMyUnit;

interface

type

  [TestFixture]
  TMyTestClass = class
  public
    [Test]
    [TestCase('CaseX', '1')]
    [TestCase('CaseX', '2')]
    [TestCase('CaseX', '3')]
    procedure RunTest(const aParam: integer);
  end;

要运行这 3 个测试用例,请使用参数运行:

<块引用>

-run:rMyUnit.TMyTestClass.RunTest.CaseX