Search in sources :

Example 1 with IReporter

use of org.testng.IReporter in project seleniumRobot by bhecquet.

the class SeleniumTestsContext method setReporterPluginClasses.

public void setReporterPluginClasses(String classNames) {
    if (classNames != null) {
        List<Class<IReporter>> reporterClasses = new ArrayList<>();
        for (String className : classNames.split(",")) {
            try {
                Class<IReporter> clazz = (Class<IReporter>) Class.forName(className);
                if (!IReporter.class.isAssignableFrom(clazz)) {
                    throw new ClassCastException();
                }
                reporterClasses.add(clazz);
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException(String.format("Class %s cannot be loaded: %s", className, e.getMessage()));
            } catch (ClassCastException e) {
                throw new ConfigurationException(String.format("Class %s does not implement IReporter interface", className));
            }
        }
        setAttribute(REPORTER_PLUGIN_CLASSES, reporterClasses);
    } else {
        setAttribute(REPORTER_PLUGIN_CLASSES, new ArrayList<>());
    }
}
Also used : IReporter(org.testng.IReporter) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) ArrayList(java.util.ArrayList)

Aggregations

ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 ArrayList (java.util.ArrayList)1 IReporter (org.testng.IReporter)1