To get the most out of running your test in Perfecto, you need to create an instance of the Smart Reporting client (ReportiumClient ). This will allow you to later retrieve and analyze the test report. The reporting client is responsible for gathering basic information about the test and transmitting it to the Smart Reporting system. In Utils.java, we show how to use the ReportiumClientFactory class' createPerfectoReportiumClient() method. Use the PerfectoExecutionContext classto supply the link to the factory class creating the client instance. Use the withWebDriver() method to supply the link of the driver instance. Use the build() method to create the context object's instance and supply this to the createPerfectoReportiumClient() method when creating the ReportiumClient instance. Code Block |
---|
| PerfectoExecutionContext perfectoExecutionContext;
if(System.getProperty("reportium-job-name") != null) {
perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
.withProject(new Project("My Project", "1.0"))
.withJob(new Job(System.getProperty("reportium-job-name") , Integer.parseInt(System.getProperty("reportium-job-number"))))
.withContextTags("tag1")
.withWebDriver(driver)
.build();
} else {
perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
.withProject(new Project("My Project", "1.0"))
.withContextTags("tag1")
.withWebDriver(driver)
.build();
}
ReportiumClient reportiumClient = new ReportiumClientFactory().createPerfectoReportiumClient(perfectoExecutionContext); |
In addition to supplying the driver link, the context supports optional settings, such as adding: - Reporting tags: Tags are used as a freestyle text for filtering the reports in the Reporting app. Use the
withContextTags() method as shown in the above code snippet. - CI job information: Job information is used to add your test runs to the CI Dashboard view. Use the
withJob() method of the PerfectoExecutionContext instance, supplying the job name and job number, when creating the ReportiumClient instance. Our sample script uses system variables to fetch the reportium-job-name and the reportium-job-number values . Both system variables are sent from CI tools like Jenkins as a Maven -D system property. For example:
-Dreportium-job-name=${JOB_NAME} -Dreportium-job-number=${BUILD_NUMBER} The following figure illustrates how the reportium-job-name and the reportium-job-number system variables get their value from Jenkins. These variables are passed as -D parameters for install goals of Maven.
 Our script supports both local and CI-based executions (for more information, see Add reporting to Jenkins > Supply Maven or Ivy parameters).
|