All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.grasshopper.test.ExtentTestManager Maven / Gradle / Ivy

There is a newer version: 2.16.0
Show newest version
package tech.grasshopper.test;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.observer.ExtentObserver;

import tech.grasshopper.pojo.Feature;
import tech.grasshopper.reporters.ReporterInitializer;
import tech.grasshopper.test.heirarchy.DefaultExtentTestHeirarchy;

@Singleton
public class ExtentTestManager {

	private ExtentReports extent;
	private ReporterInitializer reportInitializer;
	private DefaultExtentTestHeirarchy testHeirarchy;

	@Inject
	public ExtentTestManager(ReporterInitializer reportInitializer, DefaultExtentTestHeirarchy testHeirarchy) {
		this.extent = new ExtentReports();
		this.reportInitializer = reportInitializer;
		this.testHeirarchy = testHeirarchy;
	}

	public void initialize(List features) {
		Map> reporters = reportInitializer.getReportKeyToInstance();
		extent.setReportUsesManualConfiguration(true);
		testHeirarchy.createTestHeirarchy(features, extent);
		
		for (String key : reporters.keySet()) {
			ExtentObserver reporter = reporters.get(key);
			extent.attachReporter(reporter);
		}	
	}

	public void flushToReporters() {
		extent.flush();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy