Java源码示例:gherkin.formatter.Reporter

示例1
private ThreadAwareReporter(ThreadAwareFormatter threadAwareWrappedFormatter, 
		final ClassLoader classLoader,
		final RuntimeOptions runtimeOptions) {
	this.threadAwareWrappedFormatter = threadAwareWrappedFormatter;
	this.classLoader = classLoader;
	this.runtimeOptions = runtimeOptions;
	threadLocal = new ThreadLocal<Reporter>() {
      		@Override
      		protected Reporter initialValue() {
      			return runtimeOptions.reporter(classLoader);
      		}
      	};
}
 
示例2
@Override
public void after(Match arg0, Result arg1) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.after(arg0, arg1);
	}
}
 
示例3
@Override
public void before(Match arg0, Result arg1) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.before(arg0, arg1);
	}
	
}
 
示例4
@Override
public void embedding(String arg0, byte[] arg1) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.embedding(arg0, arg1);
	}
	
}
 
示例5
@Override
public void match(Match arg0) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.match(arg0);
	}
	
}
 
示例6
@Override
public void result(Result arg0) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.result(arg0);
	}
	
}
 
示例7
@Override
public void write(String arg0) {
	Reporter wrappedReporter = getWrappedReporter();
	if(wrappedReporter != null) {
		wrappedReporter.write(arg0);
	}
	
}
 
示例8
/**
	 * Constructor looping though the {@link Parameterized} {@link Runner}'s and
	 * adding the {@link CucumberFeature}'s found as children to each one
	 * ensuring the {@link TestEnvironment} is available for each {@link Runner}
	 * .
	 * 
	 * @param klass
	 * @throws Throwable
	 */
	public ParameterizedCucumber(Class<?> klass) throws Throwable {
    	
    	super(klass);
        
        log.debug("Initializing the ParameterizedCucumber runner");

        final ClassLoader classLoader = klass.getClassLoader();
        Assertions.assertNoCucumberAnnotatedMethods(klass);

//        Class<? extends Annotation>[] annotationClasses = new Class[]{CucumberOptions.class, Options.class};
//        RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(klass, annotationClasses);
        RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(klass);
        final RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();

        ResourceLoader resourceLoader = new MultiLoader(classLoader);
//        ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
//        runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
        runtime = new Runtime(resourceLoader, classLoader, runtimeOptions);
        
        final ThreadAwareFormatter threadAwareWrappedFormatter = new ThreadAwareFormatter(runtimeOptions, classLoader);
        
        
        Reporter threadAwareReporter = new ThreadAwareReporter(threadAwareWrappedFormatter, classLoader, runtimeOptions);
        
		
		runtimeOptions.formatters.clear();
		runtimeOptions.formatters.add(threadAwareWrappedFormatter);
		
        jUnitReporter = new JUnitReporter(threadAwareReporter, threadAwareWrappedFormatter, runtimeOptions.strict);
        //overwrite the reporter so we can alter the path to write to
        
        List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader);
        List<Runner> parameterizedChildren = super.getChildren();
        final SeleniumManager seleniumManager = SenBotContext.getSenBotContext().getSeleniumManager();
        final CucumberManager cucumberManager = SenBotContext.getSenBotContext().getCucumberManager();

        for (int i = 0; i < parameterizedChildren.size(); i++) {
        	BlockJUnit4ClassRunner paramRunner = (BlockJUnit4ClassRunner) parameterizedChildren.get(i);
        	final TestEnvironment environment = seleniumManager.getSeleniumTestEnvironments().get(i);
        
        	log.debug("Load runners for test envrironment: " + environment.toString());
        	
            for (final CucumberFeature cucumberFeature : cucumberFeatures) {
            	Feature originalFeature = cucumberFeature.getGherkinFeature();
            	
            	log.debug("Load runner for test cucumberFeature: " + originalFeature.getDescription() + " on evironment " + environment.toString());
                
            	ThreadPoolFeatureRunnerScheduler environmentFeatureRunner = new ThreadPoolFeatureRunnerScheduler(environment, 
            			cucumberFeature, 
            			runtime, 
            			jUnitReporter,
            			cucumberManager.getFeatureFileTimeout());
            	
            	setScheduler(environmentFeatureRunner);
				children.add(environmentFeatureRunner);
            }           
        }

    }
 
示例9
private Reporter getWrapped() {
	return threadLocal.get();
}
 
示例10
private Reporter getWrappedReporter() {
	if(Reporter.class.isAssignableFrom(getWrapped().getClass())) {
		return (Reporter) getWrapped();
	}
	return null;
}