gherkin.formatter.model.Tag Java Examples

The following examples show how to use gherkin.formatter.model.Tag. 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: GherkinKeyWordProvider.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void scenario(Scenario xTest) {
	currentSection = Section.SCENARIOS;
       String tagNames = null;
       if ( xTest.getTags() != null && !xTest.getTags().isEmpty() )
       {
           tagNames = "";
           for ( Tag tagName : xTest.getTags() )
               tagNames = tagNames + tagName.getName() + ",";
           
           tagNames = tagNames.substring( 0, tagNames.length() - 1 );
       }
       
       this.currentScenario = new KeyWordTest( xTest.getName(), true, null, null, false, null, null, 0, xTest.getDescription(), tagNames, null, null, null, 0, null, null, null, null, 0, 0, TRACE.OFF.name() );

       for ( KeyWordStep xStep : backgroundSteps )
           this.currentScenario.addStep( xStep );
       
       log.info( "Adding " + xTest.getName() );
       scenarioList.add( currentScenario );
	
}
 
Example #2
Source File: GherkinKeyWordProvider.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void scenarioOutline(ScenarioOutline xTest) {
	currentSection = Section.OUTLINE;
       String tagNames = null;
       if ( xTest.getTags() != null && !xTest.getTags().isEmpty() )
       {
           tagNames = "";
           for ( Tag tagName : xTest.getTags() )
               tagNames = tagNames + tagName.getName() + ",";
           
           tagNames = tagNames.substring( 0, tagNames.length() - 1 );
       }
       
       this.currentScenario = new KeyWordTest( xTest.getName(), true, null, xTest.getName(), false, null, null, 0, xTest.getDescription(), tagNames, null, null, null, 0, null, null, null, null, 0, 0, TRACE.OFF.name() );

       for ( KeyWordStep xStep : backgroundSteps )
           this.currentScenario.addStep( xStep );
       
       log.info( "Adding " + xTest.getName() );
       scenarioList.add( currentScenario );
	
}
 
Example #3
Source File: XMLFormatter.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void scenario( Scenario xTest )
{
    currentSection = Section.SCENARIOS;
    String tagNames = null;
    if ( xTest.getTags() != null && !xTest.getTags().isEmpty() )
    {
        tagNames = "";
        for ( Tag tagName : xTest.getTags() )
            tagNames = tagNames + tagName.getName() + ",";
        
        tagNames = tagNames.substring( 0, tagNames.length() - 1 );
    }
    
    this.currentScenario = new KeyWordTest( xTest.getName(), true, null, null, false, null, null, 0, xTest.getDescription(), tagNames, null, null, configProperties, 0, null, null, null, null, 0, 0, TRACE.OFF.name() );

    for ( KeyWordStep xStep : backgroundSteps )
        this.currentScenario.addStep( xStep );
    scenarioList.add( currentScenario );
}
 
Example #4
Source File: XMLFormatter.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void scenarioOutline( ScenarioOutline xTest )
{
    
    currentSection = Section.OUTLINE;
    String tagNames = null;
    if ( xTest.getTags() != null && !xTest.getTags().isEmpty() )
    {
        tagNames = "";
        for ( Tag tagName : xTest.getTags() )
            tagNames = tagNames + tagName.getName() + ",";
        
        tagNames = tagNames.substring( 0, tagNames.length() - 1 );
    }
    
    this.currentScenario = new KeyWordTest( xTest.getName(), true, null, xTest.getName(), false, null, null, 0, xTest.getDescription(), tagNames, null, null, configProperties, 0, null, null, null, null, 0, 0, TRACE.OFF.name() );

    for ( KeyWordStep xStep : backgroundSteps )
        this.currentScenario.addStep( xStep );

    scenarioList.add( currentScenario );
}
 
Example #5
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 6 votes vote down vote up
private TestCaseId getTestCaseIdAnnotation(Scenario scenario) {
    for (Tag tag : scenario.getTags()) {
        Matcher matcher = TEST_CASE_ID_PATTERN.matcher(tag.getName());
        if (matcher.matches()) {
            final String testCaseId = matcher.group(1);
            return new TestCaseId() {
                @Override
                public String value() {
                    return testCaseId;
                }

                @Override
                public Class<TestCaseId> annotationType() {
                    return TestCaseId.class;
                }
            };
        }
    }

    return null;
}
 
Example #6
Source File: AllureCucumberJvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void startOfScenarioLifeCycle(final Scenario scenario) {
    this.currentScenario = scenario;

    final Deque<Tag> tags = new LinkedList<>(scenario.getTags());

    if (SCENARIO_OUTLINE_KEYWORDS.contains(scenario.getKeyword())) {
        synchronized (gherkinSteps) {
            gherkinSteps.clear();
        }
    } else {
        tags.addAll(currentFeature.getTags());
    }

    final LabelBuilder labelBuilder = new LabelBuilder(currentFeature, scenario, tags);

    final String uuid = UUID.randomUUID().toString();
    scenarioUuids.put(scenario, uuid);

    final TestResult result = new TestResult()
            .setUuid(uuid)
            .setHistoryId(StepUtils.getHistoryId(scenario.getId()))
            .setFullName(String.format("%s: %s", currentFeature.getName(), scenario.getName()))
            .setName(scenario.getName())
            .setLabels(labelBuilder.getScenarioLabels())
            .setLinks(labelBuilder.getScenarioLinks());

    if (!currentFeature.getDescription().isEmpty()) {
        result.setDescription(currentFeature.getDescription());
    }

    lifecycle.scheduleTestCase(result);
    lifecycle.startTestCase(uuid);

}
 
Example #7
Source File: CucumberListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
private String[] getTagArray(List<Tag> tags) {
    String[] tagArray = new String[tags.size()];
    for (int i = 0; i < tags.size(); i++) {
        tagArray[i] = tags.get(i).getName();
    }
    return tagArray;
}
 
Example #8
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
private SeverityLevel getSeverityLevel(Scenario scenario) {
    SeverityLevel level = null;
    List<SeverityLevel> severityLevels = Arrays.asList(
            SeverityLevel.BLOCKER,
            SeverityLevel.CRITICAL,
            SeverityLevel.NORMAL,
            SeverityLevel.MINOR,
            SeverityLevel.TRIVIAL);
    for (Tag tag : scenario.getTags()) {
        Matcher matcher = SEVERITY_PATTERN.matcher(tag.getName());
        if (matcher.matches()) {
            SeverityLevel levelTmp;
            String levelString = matcher.group(1);
            try {
                levelTmp = SeverityLevel.fromValue(levelString.toLowerCase());
            } catch (IllegalArgumentException e) {
                LOG.warn(String.format("Unexpected Severity level [%s]. SeverityLevel.NORMAL will be used instead", levelString), e);
                levelTmp = SeverityLevel.NORMAL;
            }

            if (level == null || severityLevels.indexOf(levelTmp) < severityLevels.indexOf(level)) {
                level = levelTmp;
            }
        }
    }
    return level;
}
 
Example #9
Source File: AllureReporter.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
private Issues getIssuesAnnotation(Scenario scenario) {
    List<String> issues = new ArrayList<>();
    for (Tag tag : scenario.getTags()) {
        Matcher matcher = ISSUE_PATTERN.matcher(tag.getName());
        if (matcher.matches()) {
            issues.add(matcher.group(1));
        }
    }
    return !issues.isEmpty() ? getIssuesAnnotation(issues) : null;
}
 
Example #10
Source File: TagParser.java    From allure-java with Apache License 2.0 4 votes vote down vote up
protected boolean isResultTag(final Tag tag) {
    return Arrays.asList(new String[]{FLAKY, KNOWN, MUTED})
            .contains(tag.getName().toUpperCase());
}
 
Example #11
Source File: TagParser.java    From allure-java with Apache License 2.0 4 votes vote down vote up
protected boolean isPureSeverityTag(final Tag tag) {
    return Arrays.stream(SeverityLevel.values())
            .map(SeverityLevel::value)
            .map(value -> "@" + value)
            .anyMatch(value -> value.equalsIgnoreCase(tag.getName()));
}
 
Example #12
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 #13
Source File: LabelBuilder.java    From allure-java with Apache License 2.0 4 votes vote down vote up
private Label getTagLabel(final Tag tag) {
    return createTagLabel(tag.getName().substring(1));
}