TestInsights seems to not recognize runParam to exclude DUnitX Tests by category

Issue #160 resolved
Mario Allegro created an issue

Hello,

I tried everything possible to get my tests, which have a category applied, not executed by testinsights.
But I am somehow not able to do so.

  • We are using DUnitX as the testing framework
  • We categorize our unit tests

    * We have used the standard code by testinsights to register the tests * We added the call to the procedure TDUnitX.CheckCommandLine

  • We added a run parameter

Hope you can give me a hint and put me on the right track again.

Best regards,
Mario!

Comments (4)

  1. Stefan Glienke repo owner

    Hi Mario,

    the CheckCommandLine call potentially causes some filters to be built which TI just overrides.

    Please change the code as follows:

    procedure RunRegisteredTests(const baseUrl: string);
    var
      client: ITestInsightClient;
      logger: TTestInsightLogger;
      runner: ITestRunner;
      results: IRunResults;
      filter: ITestFilter;
      andFilter: IAndFilter;
    begin
      client := TTestInsightRestClient.Create(baseUrl);
      logger := TTestInsightLogger.Create(client);
      TDUnitX.CheckCommandLine;
      filter := TSelectedFilter.Create(client, logger.IncTestCount);
      if Assigned(TDUnitX.Filter) then
      begin
        andFilter := TAndFilter.Create(TDUnitX.Filter);
        andFilter.Add(filter);
        filter := andFilter;
      end;
      TDUnitX.Filter := filter;
      runner := TDUnitXTestRunner.Create(logger);
      runner.FailsOnNoAsserts := True;
      runner.UseRTTI := True;
      results := runner.Execute;
      TDUnitX.Filter := nil;
    end;
    

    I will consider changing this for some upcoming version.

  2. Log in to comment