@Test public void instantiates_the_driver_specified_in_the_RunVia_annotation() { Driver driver = driverFinder.findTestClassDriver(DummyTestClass.class); assertThat(driver, is(instanceOf(DummyDriver.class))); }
@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); } }
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); } } }
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); } }  }
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); } }  @Override Driver findTestClassDriver(Class<?> testClass); }
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); } }  @Override Driver findTestClassDriver(Class<?> testClass);  }