我编写了一个过程,它接受一个测试套件和一个测试名称列表,用一个匹配的名称禁用所有测试,还执行对嵌套测试套件的递归。
procedure DisableTests(const ATest: ITest; const AExclude: TStrings);
var
I: Integer;
begin
if AExclude.IndexOf(ATest.Name) <> -1 then
begin
ATest.Enabled := False;
end;
for I := 0 to ATest.Tests.Count - 1 do
begin
DisableTests(ATest.Tests[I] as ITest, AExclude);
end
end;
示例用法(TStringlist Excludes是在Setup方法中创建的):
procedure TSuiteVersion1beta2.SetUp;
begin
// fill test suite
inherited;
// exclude some tests because they will fail anyway
Excludes.Add('TestA');
Excludes.Add('TestB');
DisableTests(Self, Excludes);
end;