Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mpkorstanje opened this issue Feb 15, 2024 · 1 comment
Open
Assignees
Labels
🏦 debt Tech debt

Comments

@mpkorstanje
Copy link
Contributor

πŸ€” 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

@mpkorstanje mpkorstanje self-assigned this Feb 15, 2024
@kieran-ryan kieran-ryan added the 🏦 debt Tech debt label Feb 15, 2024
@mpkorstanje mpkorstanje changed the title Test java implementation against test/data/good Test java and javascript implementation against test/data/good Feb 19, 2024
@mpkorstanje
Copy link
Contributor Author

See also the comments in #53 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏦 debt Tech debt
Projects
None yet
Development

No branches or pull requests

2 participants