Пример #1
0
 @SuppressWarnings("unchecked")
 public Object getInstance(Line line, Class clas)
     throws InstantiationException, IllegalAccessException {
   Fixture annotation = (Fixture) clas.getAnnotation(Fixture.class);
   Lifespan lifespan = annotation.lifespan();
   Object instance;
   if (lifespan == Lifespan.FULL_SUITE) {
     instance = fullSuiteCache.getInstance(clas);
   } else if (lifespan == Lifespan.FEATURE) {
     Feature feature = line.getScenario().getFeature();
     instance = featureCache.cache(clas, feature);
   } else if (lifespan == Lifespan.SCENARIO) {
     Scenario scenario = line.getScenario();
     instance = scenarioCache.cache(clas, scenario);
   } else {
     LOG.info("create new instance of '{}'", clas);
     instance = clas.newInstance();
   }
   return instance;
 }