forked from cucumber/gherkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_info.txt
40 lines (31 loc) · 1.37 KB
/
_info.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
To test specific feature file, add below code
in `java/src/test/java/io/cucumber/gherkin/GherkinTest.java`:
@Test
public void test_successful_token_matching() throws IOException {
List<String> paths = singletonList("testdata/good/rule_with_tag.feature");
// Get the AST
for (String featureFilePath: paths)
{
TokenMatcher tokenMatcher = new TokenMatcher();
Path path = Paths.get(featureFilePath);
String featureContent = new String(Files.readAllBytes(path));
String featureTokens = TokensGenerator.generateTokens(featureContent, tokenMatcher);
String tokenFilePath = featureFilePath + ".tokens";
path = Paths.get(tokenFilePath);
String expectedTokensText = new String(Files.readAllBytes(path));
assertEquals(expectedTokensText, featureTokens);
}
}
Also, create the source below at
`java/src/test/java/io/cucumber/gherkin/TokensGenerator.java`:
package io.cucumber.gherkin;
public class TokensGenerator
{
public static String generateTokens(String featureContent
, Parser.ITokenMatcher tokenMatcher)
{
TokenFormatterBuilder tokenFormatterBuilder = new TokenFormatterBuilder();
Parser<String> parser = new Parser<>(tokenFormatterBuilder);
return parser.parse(featureContent, tokenMatcher);
}
}