Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.1.2] - Gherkin comments support

* Add support for Gherkin comments (lines starting with `#`)

## [2.1.1] - Improve data table step detection

* Fix data table step detection when combined with scenario outline
Expand Down
5 changes: 5 additions & 0 deletions lib/src/bdd_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum LineType {
scenario,
scenarioOutline,
step,
comment,
dataTableStep,
after,
examples,
Expand Down Expand Up @@ -54,6 +55,9 @@ LineType _lineTypeFromString(String line) {
if (tagMarkers.any((marker) => line.startsWith(marker))) {
return LineType.tag;
}
if (commentMarkers.any((marker) => line.startsWith(marker))) {
return LineType.comment;
}
return LineType.unknown;
}

Expand All @@ -66,6 +70,7 @@ const scenarioOutlineMarkers = ['Scenario Outline:'];
const stepMarkers = ['Given', 'When', 'Then', 'And', 'But'];
const examplesMarkers = ['|'];
const examplesTitleMarkers = ['Examples:', 'Scenarios:'];
const commentMarkers = ['#'];

String _removeLinePrefix(String rawLine) {
final lines = rawLine.split(' ');
Expand Down
4 changes: 3 additions & 1 deletion lib/src/feature_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class FeatureFile {
List<StepFile> getStepFiles() => _stepFiles;

static List<BddLine> _prepareLines(Iterable<BddLine> input) {
final inputList = input.toList(growable: false);
final inputList = input
.where((line) => line.type != LineType.comment)
.toList(growable: false);
final lines = inputList
.mapIndexed(
(index, bddLine) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bdd_widget_test
description: A BDD-style widget testing library. Generates Flutter widget tests from *.feature files.
version: 2.1.1
version: 2.1.2
repository: https://github.com/olexale/bdd_widget_test
issue_tracker: https://github.com/olexale/bdd_widget_test/issues

Expand Down
37 changes: 37 additions & 0 deletions test/comment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,43 @@ import 'package:flutter_test/flutter_test.dart';

import './step/the_app_is_running.dart';

void main() {
group(\'\'\'Testing feature\'\'\', () {
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
await theAppIsRunning(tester);
});
});
}
''';

final feature = FeatureFile(
featureDir: 'test.feature',
package: 'test',
input: featureFile,
);
expect(feature.dartContent, expectedFeatureDart);
});

test('Gherkin comments are ignored', () {
const featureFile = '''
# This is a comment

Feature: Testing feature
#One more comment
Scenario: Testing scenario
# Another comment
Given the app is running
''';

const expectedFeatureDart = '''
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import './step/the_app_is_running.dart';

void main() {
group(\'\'\'Testing feature\'\'\', () {
testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
Expand Down
3 changes: 3 additions & 0 deletions test/full_set_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import 'package:test/test.dart';
void main() {
test('fully custom test ', () {
const featureFile = '''
# This is a comment
@customFeatureTag
Feature: Counter
This is a comment too
Background:
Given the app is running
After:
Expand All @@ -19,6 +21,7 @@ Feature: Counter
Then I see {'0'} text
Feature: Counter 2
Background:
#One more comment
Given the app is running
Scenario: Initial counter value is 0
Given the app is running
Expand Down