Skip to content

Test java and javascript implementation against test/data/good #59

@mpkorstanje

Description

@mpkorstanje

🤔 What's the problem you've observed?

The java implementation currently doesn't test itself against the examples in testdata/good.

✨ Do you have a proposal for making it better?

Copy the Javascript implementation

const featureFiles = fg.sync(`${__dirname}/../../testdata/good/*.feature`)
for (const featureFile of featureFiles) {
const relativePath = path.relative(__dirname, featureFile)
it(`renders ${relativePath}`, () => {
const gherkinSource = fs.readFileSync(featureFile, 'utf-8')
const gherkinDocument = parse(gherkinSource, new GherkinClassicTokenMatcher())
const formattedGherkinSource = pretty(gherkinDocument, 'gherkin')
const language = gherkinDocument.feature?.language || 'en'
const newGherkinDocument = checkGherkinToAstToGherkin(formattedGherkinSource, language)
assert(newGherkinDocument)
// TODO: comments
if (gherkinDocument.comments.length === 0) {
assert.deepStrictEqual(neutralize(newGherkinDocument), neutralize(gherkinDocument))
}
})
}

This can be done with JUnit 5's Parameterized tests. For example see:

https://github.com/cucumber/cucumber-expressions/blob/main/java/src/test/java/io/cucumber/cucumberexpressions/CucumberExpressionTest.java

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions