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

Cucumber data table #56

Merged
merged 21 commits into from
Jan 23, 2024
Merged

Cucumber data table #56

merged 21 commits into from
Jan 23, 2024

Conversation

ron-brosh
Copy link
Contributor

Based on the Cucumber documentation, there's a way to support tabular data using a class called DataTable.
That class can return the data to the consumer in three ways:

  1. list of lists
  2. list of maps
  3. custom table transformer

This PR adds the DataTable model with the first two use cases.

  • DataTable is also available as a widget in the material package so in our context it's prefixed with the import's bdd:
import 'package:bdd_widget_test/src/data_table.dart' as bdd;
  • Added unit tests
  • Tested generated feature file
  • 100% coverage on new changes
Screenshot 2024-01-12 at 15 53 55

Copy link
Owner

@olexale olexale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ron-brosh,
Thanks for the PR. I made a few suggestions and comments, please review.

.gitignore Outdated Show resolved Hide resolved
lib/src/data_table.dart Outdated Show resolved Hide resolved
lib/src/data_table.dart Outdated Show resolved Hide resolved
@@ -10,6 +10,10 @@ class BddLine {
final LineType type;
}

class DataTableBddLine extends BddLine {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types for all other lines from features files are described in LineType enum. Are there any reason why the data table line can not follow the same pattern?

Copy link
Contributor Author

@ron-brosh ron-brosh Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides _lineTypeFromString which needs the next lines in order to determine the dataTable type, the
step enum is used in the generation logic which fails the tests when I add the new type.
It also adds a lot of boilerplate (will have to be repeated in multiple places):

if(type = LineType.step || type == LineType.dataTable)

LineType enum describes unique lines that can be map to those types.
A cucumber data table is determined by the combination of a step and examples.
I'll be happy to explore any proposal that might simplify and keep the existing convention though.

Copy link
Contributor Author

@ron-brosh ron-brosh Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new enum value dataTableStep and modified the StepFile.create to accept the domain model BDD line instead of its internal implementation details.

lib/src/data_table_parser.dart Outdated Show resolved Hide resolved
lib/src/data_table_parser.dart Outdated Show resolved Hide resolved
lib/src/data_table_parser.dart Outdated Show resolved Hide resolved
lib/src/data_table_parser.dart Outdated Show resolved Hide resolved
lib/src/data_table_parser.dart Outdated Show resolved Hide resolved
lib/src/step/generic_step.dart Outdated Show resolved Hide resolved
@ron-brosh ron-brosh requested a review from olexale January 22, 2024 20:31
@olexale olexale merged commit a81852e into olexale:master Jan 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants