I used the Status () method, which will output the value when a failure occurs:
procedure Test.TestGetStringListQueryValuesException; var ReturnValue: TList<String>; item: String; begin ReturnValue := FTest.GetStringListQueryValues; try for item in ReturnValue do begin Status('Value Processed: ' + item); CheckTrue(Pos('B', item) > 0, 'Wrong Value, Expected Item containing ''B'' but found: ' + item); end; finally ReturnValue.Free; end; end;
The result is something like this:
TestGetIntegerListQueryValuesException: ETestFailure at $0050B842 Wrong Value, Expected > 50 and < 60 but found: 61, expected: <True> but was: <False> Status Messages Value Processed: 52 Value Processed: 54 Value Processed: 55 Value Processed: 58 Value Processed: 59 Value Processed: 61
It is very helpful to determine what went wrong during the test. I have not tried SetStatusListener (), but I think this should be the right way if we want to show the log when the test succeeded.
I would like to imitate the same behavior as in Nunit, where you can log custom messages in the output section.
Any better ideas?
source share