Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Using the Perfecto Execution context
Code Block
languagejava
themeMidnight
titleJava sample code
linenumberstrue
collapsetrue
	// 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()))
	.withBranch("awesome_vcs_branch");


	// 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", "sdet1@awesomecompany.com");

	// Add the custom field to custom field collection.
	customFields.add(author);
	
	// 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();
Code Block
languagejs
themeMidnight
titleJavascript sample code
linenumberstrue
collapsetrue
	// Define CustomFields Object
	var customFieldsObject = {
		'author':'sdet1@awesomecompany.com'
    };

	// 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