by Prasant Sutaria

Pre-requisite - Basic Smart reporting API implementation in your framework.

Perfecto provides standard information regarding test case execution, which can be used to analyze and group test case(s). For example: operation system version, device name, status of test cases, and so on. This metadata can be utilized for efficient test execution analysis and to group test cases. For more information on standard reporting fields, see Access and navigate the Test Analysis UI.

Perfecto's Smart Reporting lets you define custom-field <Key, Value> pairs to provide additional information regarding the test case, for example the name of test script's author. This information can be useful for the maintenance of test script, and so on.

You can define custom fields using:

Note: In case of conflict in keys, the test context has higher precedence.

The following code samples illustrate how to implement custom fields.

Using the Perfecto Execution context
	// Define other fields like tags, project, and job details.
	Project project = new Project(reportConstants.getProjectName(), reportConstants.getProjectVersion());

	Job job = new Job(reportConstants.getJobName(), Integer.parseInt(reportConstants.getJobVersion()))

	// create a list of custom fields.
	List<CustomField> customFields = new ArrayList<CustomField>();

	// Define a custom field with Key value pair.
	CustomField author = new CustomField("author", "");

	// Add the custom field to custom field collection.
	// Perfecto Execution Context definition.
	PerfectoExecutionContext execContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
	.withContextTags(tags)			// Add tags to Perfecto Execution Context	
	.withProject(project)			// Add Project details to Perfecto Execution Context
	.withJob(job)					// Add Job details to Perfecto Execution Context	
	.withCustomFields(customFields)	// Add Custom fields to Perfecto Execution Context
	.withWebDriver((WebDriver) driver).build();
	// Define CustomFields Object
	var customFieldsObject = {

	// Initializing Perfecto Execution Context
	var executionContext = await new Reporting.Perfecto.PerfectoExecutionContext({
		webdriver: browser.driver,
		job: new Reporting.Model.Job({
			jobName:  this.pJobName,
			buildNumber: this.pJobNumber,
			branch: this.pBranchName
		customFields: customFieldsObject,
		tags: ["awesome"]
	// Initializing Reportium client
	browser.reportingClient = await new Reporting.Perfecto.PerfectoReportingClient(executionContext);

Some interesting use case of custom field - Custom field use case