Unit Command.Test
Description
This unit contains procedures to configure and execute a command to create dipslay unit tests colored output. Also should display source code location for each failed test.
If a heap trace file is found on test project directory an output with possible leaks is generated.
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Record TTestRunResult |
Result of a test project execution. |
Functions and Procedures
procedure TestCommand(ABuilder: ICommandBuilder); |
function RunTests(ABuilder: ICommandBuilder; const ABuild: Boolean): TTestRunResult; |
function BuildTestProject(ABuilder: ICommandBuilder; const AProjectFile: string; const ABuildMode: string = ''): Boolean; overload; |
function BuildTestProject(ABuilder: ICommandBuilder; const AProjectFile, ABuildMode: string; out AError: string): Boolean; overload; |
function FirstBuildError(const AOutput: string): string; |
procedure Registry(ABuilder: ICommandBuilder); |
function FindTestProject(ABuilder: ICommandBuilder; const AQuiet: Boolean = False): string; |
function GetTestExecutable(ABuilder: ICommandBuilder): string; |
Description
Functions and Procedures
procedure TestCommand(ABuilder: ICommandBuilder); |
|
This command searches for a fpcunit test project in the current folder or in a tests subfolder, builds it using lazbuild and runs it. At the end of the execution, an xml file with the same name as the test project is expected to be read. From this reading, a result is generated with the objective of highlighting the tests that failed, formatting the name of the source code file with a line and column in a format that vscode is able to understand and providing the developer with a link for quick navigation through the code. If a memory leak trace file named heap.trc is found, the command also outputs information with details about the possible memory leaks in a format that vscode can provide easy navigation through the code.
Parameters
|
function RunTests(ABuilder: ICommandBuilder; const ABuild: Boolean): TTestRunResult; |
|
Runs the test project found from the current directory and outputs the report. If ABuild is true the test project is built with lazbuild before running. Returns whether the tests ran and how many passed and failed.
Parameters
|
function BuildTestProject(ABuilder: ICommandBuilder; const AProjectFile: string; const ABuildMode: string = ''): Boolean; overload; |
|
Builds the test project using lazbuild. The .lpi file with the same name of the project file is preferred if it exists. Returns true if the build succeeded.
Parameters
|
function BuildTestProject(ABuilder: ICommandBuilder; const AProjectFile, ABuildMode: string; out AError: string): Boolean; overload; |
|
Builds the test project like the other BuildTestProject, and returns in AError the first error of the compiler when the build fails, for a summary.
Parameters
|
function FirstBuildError(const AOutput: string): string; |
|
Returns the first error in the output of lazbuild, the line that explains the failure among the hints and the lazbuild messages, like TestCommandGreet.pas(11,3) Fatal: Can't find unit Command.Interfaces used by TestCommandGreet. The folder of the file and the message number are removed. Returns empty if there is no error.
Parameters
|
procedure Registry(ABuilder: ICommandBuilder); |
|
Registry a test command using the command builder from pascli.
Parameters
|
function FindTestProject(ABuilder: ICommandBuilder; const AQuiet: Boolean = False): string; |
|
From the current directory it tries to locate an fpcunit compatible test project, in the current folder or in a tests subfolder. Returns the complete test project file name, or empty if the project does not exist or is not of the expected type.
Parameters
|
function GetTestExecutable(ABuilder: ICommandBuilder): string; |
|
From the current directory it tries to locate an fpcunit compatible test project that has been previously compiled. Returns complete test file executable name. If the function returns empty, the project does not exist or is not of the expected type.
Parameters
|
Generated by PasDoc 1.0.4.