For integration tests of Habari ActiveMQ Client libraries, I created a DUnit test suite which runs once for every version of the message broker. Unfortunately, some of the tests always fail because of known bugs in the tested version of the message broker (not the client library).
This means the test suites will never complete with 100%. For automated tests however, I need a 100% success score, otherwise, continous integration tools will detect a failed build.
DUnit does not offer a ready-made method to disable tests in a test suite by name. So I wrote a procedure which takes a test suite and a list of test names, and then disables all tests with a matching name, and also performs a recursion into nested test suites.
Here is the code, feel free to use it:
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;
Example usage (the TStringlist ‘Excludes’ is created in the Setup method):
procedure TActiveMQ541Suite.SetUp; begin // fill test suite inherited; // exclude some tests Excludes.Add('TestBytesMessages'); Excludes.Add('TestBigMessages'); DisableTests(Self, Excludes); LaunchActiveMQ('5.4.1'); end;