@NotThreadSafe
public class RunViaAnnotationDriverFinder implements DriverFinder {
@Override
public Driver findTestClassDriver(Class<?> testClass) {
RunVia annotation = testClass.getAnnotation(RunVia.class);
if (annotation == null) {
return DRIVER_NOT_FOUND;
}
Class<? extends Driver> driverClass = annotation.value();
try {
return driverClass.newInstance();
} catch (Exception e) {
throw new RuntimeException("unable to instantiate " + driverClass, e);
}