Using Rad Studio 10 Seattle, DUnitX and TestInsight, I would need to show some texts in the console or any log screen. How can it be done? I have not been able to find it in the web.
How to log in DUnitX?
1.7k views Asked by kokokok At
2
There are 2 answers
0
On
https://github.com/jsf3rd/DUnitX.git/trunk/Examples
var
runner : ITestRunner;
logger : ITestLogger;
begin
try
//Create the runner
runner := TDUnitX.CreateRunner;
runner.UseRTTI := True;
//tell the runner how we will log things
if TDUnitX.Options.ConsoleMode <> TDunitXConsoleMode.Off then
begin
logger := TDUnitXConsoleLogger.Create(TDUnitX.Options.ConsoleMode = TDunitXConsoleMode.Quiet);
runner.AddLogger(logger);
end;
//Run tests
results := runner.Execute;
System.Write('Done.. press <Enter> key to quit.');
System.Readln;
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
Here's how to add log messages, fragments copied from https://github.com/VSoftTechnologies/DUnitX/blob/d5861ce0de6a9fbfdc8c158b0b1c8614082c188d/Examples/DUnitX.Examples.General.pas
If you want to have a less convoluted syntax, you can always add an interposer for the
Assert
class like so