-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopted changes in cucumber 5.0.0 release
Cucumber min supported version 5.0.0 and QAF min supported version 3.0.0-beta-2 * Fixed #1 Parameterized background support with cucumber runner * Fixed #2 Cucumber step with Data table having more than one argument is not working when we run with TestNG using BDDFactory2
- Loading branch information
Showing
40 changed files
with
1,815 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="/qaf/build/artifacts/jars/qaf-sources.jar"/> | ||
<classpathentry kind="lib" path="/qaf/build/artifacts/jars/qaf.jar" sourcepath="/qaf/src"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=qaf-cucumber&ivyXmlPath=ivy.xml&confs=*"/> | ||
<classpathentry kind="src" path="test/src"/> | ||
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=qaf-cucumber&ivyXmlPath=ivy-test.xml&confs=*&ivySettingsPath=ivysettings.xml&loadSettingsOnDemand=false&ivyUserDir=&propertyFiles="/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/bin/ | ||
/build/ | ||
/test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor | ||
license agreements. See the NOTICE file distributed with this work for additional | ||
information regarding copyright ownership. The ASF licenses this file to | ||
you under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of | ||
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. --> | ||
<ivy-module version="2.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"> | ||
<info organisation="com.qmetry" module="qaf-cucumber" status="integration"> | ||
</info> | ||
<configurations> | ||
<conf name="compile" description="Required to compile application"/> | ||
<conf name="runtime" description="Additional run-time dependencies" extends="compile"/> | ||
<conf name="test" description="Required for test only" extends="runtime"/> | ||
<conf name="provided" description="Needed for compile, but will be present on the target platform."/> | ||
</configurations> | ||
|
||
<dependencies> | ||
<dependency org="com.qmetry" name="qaf" rev="3.0.0-beta-1" conf="compile->default"/> | ||
<dependency org="io.cucumber" name="cucumber-core" rev="5.0.0" conf="compile->default"/> | ||
<dependency org="io.cucumber" name="gherkin" rev="5.2.0" conf="compile->default"/> | ||
|
||
<dependency org="io.cucumber" name="gherkin-jvm-deps" rev="1.0.6" conf="compile->default"/> | ||
|
||
|
||
<dependency org="io.cucumber" name="cucumber-java8" rev="5.0.0" conf="test->default"/> | ||
<dependency org="io.cucumber" name="cucumber-java" rev="5.0.0" conf="test->default"/> | ||
<dependency org="io.cucumber" name="cucumber-junit" rev="5.0.0" conf="test->default"/> | ||
<dependency org="io.cucumber" name="cucumber-spring" rev="5.0.0" conf="test->default"/> | ||
<dependency org="org.springframework" name="spring-core" rev="5.2.0.RELEASE" conf="test->default"/> | ||
<dependency org="org.springframework" name="spring-beans" rev="5.2.0.RELEASE" conf="test->default"/> | ||
<dependency org="org.springframework" name="spring-context" rev="5.2.0.RELEASE" conf="test->default"/> | ||
<dependency org="org.springframework" name="spring-test" rev="5.2.0.RELEASE" conf="test->default"/> | ||
|
||
</dependencies> | ||
</ivy-module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/com/qmetry/qaf/automation/cucumber/Bdd2PickleStep.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/com/qmetry/qaf/automation/cucumber/CucumberStepMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* | ||
*/ | ||
package com.qmetry.qaf.automation.cucumber; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import com.qmetry.qaf.automation.step.BDDStepMatcherFactory.DefaultBDDStepMatcher; | ||
|
||
import io.cucumber.core.exception.CucumberException; | ||
|
||
/** | ||
* @author chirag.jayswal | ||
* | ||
*/ | ||
public class CucumberStepMatcher extends DefaultBDDStepMatcher { | ||
private static final Pattern PARAMETER_PATTERN = Pattern.compile("(\\\\\\\\)?\\{([^}]*)\\}"); | ||
private static final Pattern OPTIONAL_PATTERN = Pattern.compile("(\\\\\\\\)?\\(([^)]+)\\)"); | ||
private static final Pattern ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP = Pattern.compile("([^\\s^/]+)((/[^\\s^/]+)+)"); | ||
private static final String DOUBLE_ESCAPE = "\\\\"; | ||
private static final String PARAMETER_TYPES_CANNOT_BE_ALTERNATIVE = "Parameter types cannot be alternative: "; | ||
private static final String PARAMETER_TYPES_CANNOT_BE_OPTIONAL = "Parameter types cannot be optional: "; | ||
|
||
@Override | ||
public boolean matches(String stepDescription, String stepCall, Map<String, Object> context) { | ||
stepDescription = processOptional(stepDescription); | ||
stepDescription = processAlternation(stepDescription); | ||
return super.matches(stepDescription, stepCall, context); | ||
} | ||
|
||
@Override | ||
public List<String[]> getArgsFromCall(String stepDescription, String stepCall, Map<String, Object> context) { | ||
stepDescription = processOptional(stepDescription); | ||
stepDescription = processAlternation(stepDescription); | ||
return super.getArgsFromCall(stepDescription, stepCall, context); | ||
} | ||
|
||
private static String processOptional(String expression) { | ||
Matcher matcher = OPTIONAL_PATTERN.matcher(expression); | ||
StringBuffer sb = new StringBuffer(); | ||
while (matcher.find()) { | ||
// look for double-escaped parentheses | ||
String parameterPart = matcher.group(2); | ||
if (DOUBLE_ESCAPE.equals(matcher.group(1))) { | ||
matcher.appendReplacement(sb, "\\\\(" + parameterPart + "\\\\)"); | ||
} else { | ||
checkNotParameterType(parameterPart, PARAMETER_TYPES_CANNOT_BE_OPTIONAL); | ||
matcher.appendReplacement(sb, "(?:" + parameterPart + ")?"); | ||
} | ||
} | ||
matcher.appendTail(sb); | ||
return sb.toString(); | ||
} | ||
|
||
private static String processAlternation(String expression) { | ||
Matcher matcher = ALTERNATIVE_NON_WHITESPACE_TEXT_REGEXP.matcher(expression); | ||
StringBuffer sb = new StringBuffer(); | ||
while (matcher.find()) { | ||
// replace \/ with / | ||
// replace / with | | ||
String replacement = matcher.group(0).replace('/', '|').replaceAll("\\\\\\|", "/"); | ||
|
||
if (replacement.contains("|")) { | ||
// Make sure the alternative parts don't contain parameter types | ||
for (String part : replacement.split("\\|")) { | ||
checkNotParameterType(part, PARAMETER_TYPES_CANNOT_BE_ALTERNATIVE); | ||
} | ||
matcher.appendReplacement(sb, "(?:" + replacement + ")"); | ||
} else { | ||
// All / were escaped | ||
matcher.appendReplacement(sb, replacement); | ||
} | ||
} | ||
matcher.appendTail(sb); | ||
return sb.toString(); | ||
} | ||
|
||
private static void checkNotParameterType(String s, String message) { | ||
Matcher matcher = PARAMETER_PATTERN.matcher(s); | ||
if (matcher.find()) { | ||
throw new CucumberException(message + s); | ||
} | ||
} | ||
} |
Oops, something went wrong.