gherkin.formatter.model.Feature Java Examples

The following examples show how to use gherkin.formatter.model.Feature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Find Test classes level<p>
 * JUnit`s test {@link Description} is multilevel object with liquid
 * hierarchy.<br>
 * This method recursively query
 * {@link #getTestEntityType(org.junit.runner.Description)} method until it
 * matches {@link Feature} type and when returns parent of this object as
 * list of test classes descriptions
 *
 * @param description {@link Description} Description to start search where
 * @return {@link List<Description>} test classes description list
 * @throws IllegalAccessException
 */
public List<Description> findTestClassesLevel(List<Description> description) throws IllegalAccessException {
    if (description.isEmpty()) {
        return new ArrayList<>();
    }
    Object possibleClass = getTestEntityType(description.get(0));
    if (possibleClass instanceof String && !((String) possibleClass).isEmpty()) {
        if (!description.get(0).getChildren().isEmpty()) {
            Object possibleFeature = getTestEntityType(description.get(0).getChildren().get(0));
            if (possibleFeature instanceof Feature) {
                return description;
            } else {
                return findTestClassesLevel(description.get(0).getChildren());
            }
        } else {
            //No scenarios in feature
            return description;
        }

    } else {
        return findTestClassesLevel(description.get(0).getChildren());
    }

}
 
Example #2
Source File: StepUtils.java    From allure-java with Apache License 2.0 4 votes vote down vote up
StepUtils(final Feature feature, final Scenario scenario) {
    this.lifecycle = Allure.getLifecycle();
    this.feature = feature;
    this.scenario = scenario;
}
 
Example #3
Source File: TagParser.java    From allure-java with Apache License 2.0 4 votes vote down vote up
TagParser(final Feature feature, final Scenario scenario) {
    this.feature = feature;
    this.scenario = scenario;
}
 
Example #4
Source File: LabelBuilder.java    From allure-java with Apache License 2.0 4 votes vote down vote up
LabelBuilder(final Feature feature, final Scenario scenario, final Deque<Tag> tags) {
    final TagParser tagParser = new TagParser(feature, scenario);

    getScenarioLabels().add(createFeatureLabel(feature.getName()));
    getScenarioLabels().add(createStoryLabel(scenario.getName()));

    while (tags.peek() != null) {
        final Tag tag = tags.remove();

        final String tagString = tag.getName();

        if (tagString.contains(COMPOSITE_TAG_DELIMITER)) {

            final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2);
            if (tagParts.length < 2 || Objects.isNull(tagParts[1]) || tagParts[1].isEmpty()) {
                // skip empty tags, e.g. '@tmsLink=', to avoid formatter errors
                continue;
            }

            final String tagKey = tagParts[0].toUpperCase();
            final String tagValue = tagParts[1];

            // Handle composite named links
            if (tagKey.startsWith(PLAIN_LINK + ".")) {
                tryHandleNamedLink(tagString);
                continue;
            }

            switch (tagKey) {
                case SEVERITY:
                    getScenarioLabels().add(createSeverityLabel(tagValue.toLowerCase()));
                    break;
                case TMS_LINK:
                    getScenarioLinks().add(ResultsUtils.createTmsLink(tagValue));
                    break;
                case ISSUE_LINK:
                    getScenarioLinks().add(ResultsUtils.createIssueLink(tagValue));
                    break;
                case PLAIN_LINK:
                    getScenarioLinks().add(ResultsUtils.createLink(null, tagValue, tagValue, null));
                    break;
                default:
                    LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey);
                    getScenarioLabels().add(getTagLabel(tag));
                    break;
            }
        } else if (tagParser.isPureSeverityTag(tag)) {
            getScenarioLabels().add(createSeverityLabel(tagString.substring(1)));
        } else if (!tagParser.isResultTag(tag)) {
            getScenarioLabels().add(getTagLabel(tag));
        }
    }

    getScenarioLabels().addAll(Arrays.asList(
            createHostLabel(),
            createThreadLabel(),
            createPackageLabel(feature.getName()),
            createSuiteLabel(feature.getName()),
            createTestClassLabel(scenario.getName()),
            createFrameworkLabel("cucumberjvm"),
            createLanguageLabel("java")
    ));

}
 
Example #5
Source File: GherkinKeyWordProvider.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void feature(Feature arg0) {
	// TODO Auto-generated method stub
	
}
 
Example #6
Source File: XMLFormatter.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void feature( Feature arg0 )
{

}
 
Example #7
Source File: WrappedJSONFormatter.java    From senbot with MIT License 4 votes vote down vote up
@Override
public void feature(Feature arg0) {
	wrapped.feature(arg0);
}
 
Example #8
Source File: ParameterizedCucumber.java    From senbot with MIT License 4 votes vote down vote up
/**
	 * 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);
            }           
        }

    }
 
Example #9
Source File: ParameterizedCucumber.java    From senbot with MIT License 4 votes vote down vote up
@Override
public void feature(Feature arg0) {
	getWrapped().feature(arg0);
	
}
 
Example #10
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * Find features level<p>
 * JUnit`s test {@link Description} is multilevel object with liquid
 * hierarchy.<br>
 * This method recursively query
 * {@link #getTestEntityType(org.junit.runner.Description)} method until it
 * matches {@link Feature} type and when returns list of {@link Feature}
 * descriptions
 *
 * @param description {@link Description} Description to start search where
 * @return {@link List<Description>} features description list
 * @throws IllegalAccessException
 */
private List<Description> findFeaturesLevel(List<Description> description)
        throws IllegalAccessException {
    if (description.isEmpty()) {
        return new ArrayList<>();
    }
    Object entityType = getTestEntityType(description.get(0));
    if (entityType instanceof Feature) {
        return description;
    } else {
        return findFeaturesLevel(description.get(0).getChildren());
    }

}