fix(#222): escape single quotation marks in data tables

This commit is contained in:
Jon 2022-06-24 14:14:11 +10:00
parent 1f63ecc858
commit 6736af335e
5 changed files with 154 additions and 150 deletions

View File

@ -1,3 +1,6 @@
## [3.0.0-rc.12] - 24/06/2022
- Fix #222 - escape single quotation marks in data tables
## [3.0.0-rc.11] - 24/06/2022
- Fix #231 - Removed the use of explicitly calling `pumpAndSettle` in the pre-defined steps in favour of the implicit `pumpAndSettle` calls used in the `WidgetTesterAppDriverAdapter`.
- Added ability to add a `appLifecyclePumpHandler` to override the default handler that determines how the app is pumped during lifecycle events. Useful if your app has a long splash screen etc. Parameter is on `executeTestSuite`.

View File

@ -11,15 +11,15 @@ Feature: Creating todos
Scenario: User can create multiple new todo items
Given I fill the "todo" field with "Buy carrots"
When I tap the "add" button
And I fill the "todo" field with "Buy apples"
And I fill the "todo" field with "Buy hannah's apples"
When I tap the "add" button
And I fill the "todo" field with "Buy blueberries"
When I tap the "add" button
Then I expect the todo list
| Todo |
| Buy blueberries |
| Buy apples |
| Buy carrots |
| Todo |
| Buy blueberries |
| Buy hannah's apples |
| Buy carrots |
Given I wait 5 seconds for the animation to complete
Given I have item with data
"""

View File

@ -27,6 +27,146 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
}
void testFeature0() {
runFeature(
name: 'Swiping:',
tags: <String>['@tag'],
run: () {
runScenario(
name: 'User can swipe cards left and right',
path: '.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag', '@debug'],
steps: [
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name:
'Given I swipe right by 250 pixels on the "scrollable cards"`',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Then I expect the text "Page 2" to be present',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name:
'Given I swipe left by 250 pixels on the "scrollable cards"`',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Then I expect the text "Page 1" to be present',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
],
onBefore: () async => onBeforeRunFeature(
name: 'Swiping',
path: r'.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag'],
),
onAfter: () async => onAfterRunFeature(
name: 'Swiping',
path: r'.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag'],
),
);
},
);
}
void testFeature1() {
runFeature(
name: 'Checking data:',
tags: <String>['@tag'],
run: () {
runScenario(
name: 'User can have data',
path: '.\\integration_test\\features\\check.feature',
tags: <String>['@tag', '@tag1'],
steps: [
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Given I have item with data',
multiLineStrings: <String>[
"""{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}"""
],
table: null,
dependencies: dependencies,
skip: skip,
);
},
],
onBefore: () async => onBeforeRunFeature(
name: 'Checking data',
path: r'.\\integration_test\\features\\check.feature',
tags: <String>['@tag'],
),
onAfter: () async => onAfterRunFeature(
name: 'Checking data',
path: r'.\\integration_test\\features\\check.feature',
tags: <String>['@tag'],
),
);
},
);
}
void testFeature2() {
runFeature(
name: 'Creating todos:',
tags: <String>['@tag'],
@ -114,7 +254,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
bool skip,
) async {
return await runStep(
name: 'And I fill the "todo" field with "Buy apples"',
name: 'And I fill the "todo" field with "Buy hannah\'s apples"',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
@ -165,7 +305,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
name: 'Then I expect the todo list',
multiLineStrings: <String>[],
table: GherkinTable.fromJson(
'[{"Todo":"Buy blueberries"},{"Todo":"Buy apples"},{"Todo":"Buy carrots"}]'),
'[{"Todo":"Buy blueberries"},{"Todo":"Buy hannah\'s apples"},{"Todo":"Buy carrots"}]'),
dependencies: dependencies,
skip: skip,
);
@ -230,146 +370,6 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
},
);
}
void testFeature1() {
runFeature(
name: 'Swiping:',
tags: <String>['@tag'],
run: () {
runScenario(
name: 'User can swipe cards left and right',
path: '.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag', '@debug'],
steps: [
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name:
'Given I swipe right by 250 pixels on the "scrollable cards"`',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Then I expect the text "Page 2" to be present',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name:
'Given I swipe left by 250 pixels on the "scrollable cards"`',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Then I expect the text "Page 1" to be present',
multiLineStrings: <String>[],
table: null,
dependencies: dependencies,
skip: skip,
);
},
],
onBefore: () async => onBeforeRunFeature(
name: 'Swiping',
path: r'.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag'],
),
onAfter: () async => onAfterRunFeature(
name: 'Swiping',
path: r'.\\integration_test\\features\\swiping.feature',
tags: <String>['@tag'],
),
);
},
);
}
void testFeature2() {
runFeature(
name: 'Checking data:',
tags: <String>['@tag'],
run: () {
runScenario(
name: 'User can have data',
path: '.\\integration_test\\features\\check.feature',
tags: <String>['@tag', '@tag1'],
steps: [
(
TestDependencies dependencies,
bool skip,
) async {
return await runStep(
name: 'Given I have item with data',
multiLineStrings: <String>[
"""{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}"""
],
table: null,
dependencies: dependencies,
skip: skip,
);
},
],
onBefore: () async => onBeforeRunFeature(
name: 'Checking data',
path: r'.\\integration_test\\features\\check.feature',
tags: <String>['@tag'],
),
onAfter: () async => onAfterRunFeature(
name: 'Checking data',
path: r'.\\integration_test\\features\\check.feature',
tags: <String>['@tag'],
),
);
},
);
}
}
void executeTestSuite({

View File

@ -301,13 +301,14 @@ class FeatureFileTestGeneratorVisitor extends FeatureFileVisitor {
code = _replaceVariable(
code,
'step_multi_line_strings',
// '<String>[${multiLineStrings.map((s) => "'${_escapeText(s)}'").join(',')}]',
'<String>[${multiLineStrings.map((s) => '"""$s"""').join(',')}]',
);
code = _replaceVariable(
code,
'step_table',
table == null ? 'null' : 'GherkinTable.fromJson(\'${table.toJson()}\')',
table == null
? 'null'
: 'GherkinTable.fromJson(\'${_escapeText(table.toJson())}\')',
);
_stepBuffer.writeln(code);

View File

@ -1,6 +1,6 @@
name: flutter_gherkin
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
version: 3.0.0-rc.11
version: 3.0.0-rc.12
homepage: https://github.com/jonsamwell/flutter_gherkin
environment: