Class TTestReport

Unit

Declaration

type TTestReport = class(TObject)

Description

<sumary> This class aims to interpret the fpcunit test xml file and produce a simpler report summarizing all tests cases and also providing their location on source code. )

Hierarchy

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public class function New(ABuider: ICommandBuilder; const AProjectSource: string): TTestReport;
Public function ParseXmlTestsFile(const ATestApp, AFileName: string): TTestReport;
Public function AddItem(AItem: TTestCaseItem): TTestCaseItem;
Public procedure Output;

Properties

Public property Executable: string read FExecutable write FExecutable;
Public property ProjectSource: string read FProjectSource write FProjectSource;
Public property TestCaseCount: Integer read FTestCaseCount write FTestCaseCount;
Public property TestSuiteCount: Integer read FTestSuiteCount write FTestSuiteCount;
Public property TotalTime: string read FTotalTime write FTotalTime;
Public property TestsPassed: Integer read FTestsPassed write FTestsPassed;
Public property TestsFailed: Integer read FTestsFailed write FTestsFailed;
Public property TestCaseData: TArray<TTestCaseItem> read FTestCaseData write FTestCaseData;

Description

Methods

Public constructor Create;

Class constructor that initializes array that hold test case data. Check factory method new as the best option.

Public destructor Destroy; override;

The class's destructor frees all TTestCaseItem instances created during parse.

Public class function New(ABuider: ICommandBuilder; const AProjectSource: string): TTestReport;

It is the best way to create a new instance of the class, as it considers its dependencies.

A valid instance of ICommandBuilder. Basically it will be used to generate the output to the console considering the theme settings.)

The path to the source code, needed to find the files corresponding to the source code reported in the fpcunit xml test file. )

Public function ParseXmlTestsFile(const ATestApp, AFileName: string): TTestReport;

Parses the contents of the test xml file generated by the fpunit tests frameworkk. Groups the information into a TTestCaseItem list. It summarizes the total of tests, tests that passed, tests that failed in addition to searching for the location of the tests that failed in the source code.

Parameters
ATestApp
Test application name that will be printed along with the test report output
AFileName
Unit test xml file generated by the test application
Public function AddItem(AItem: TTestCaseItem): TTestCaseItem;

Adds a new TestCaseItem to TestCaseData, internally used by ParseXmlTestsFile.

Parameters
AItem
The item to be added to TestCaseData
Public procedure Output;

Generates a colorful and well-aligned report listing all successful and unsuccessful test cases. For failed test cases, it presents detailed information and the location of the test routine in its respective source code file.

Properties

Public property Executable: string read FExecutable write FExecutable;

Test project excutable name.

Public property ProjectSource: string read FProjectSource write FProjectSource;

Path to test project source files

Public property TestCaseCount: Integer read FTestCaseCount write FTestCaseCount;

Total test cases found on xml test file after parse

Public property TestSuiteCount: Integer read FTestSuiteCount write FTestSuiteCount;

Total test suites found on xml test file after parse

Public property TotalTime: string read FTotalTime write FTotalTime;

Total test elapsed time found on xml test file after parse

Public property TestsPassed: Integer read FTestsPassed write FTestsPassed;

Total test that passed found on xml test file after parse

Public property TestsFailed: Integer read FTestsFailed write FTestsFailed;

Total test that passed found on xml test file after parse

Public property TestCaseData: TArray<TTestCaseItem> read FTestCaseData write FTestCaseData;

All test case found on xml test file after parse


Generated by PasDoc 0.16.0.