From 4dc1fa723b52eb31ee22f3caa010781a70440b69 Mon Sep 17 00:00:00 2001 From: August Oberhauser Date: Mon, 14 Nov 2022 11:52:25 +0100 Subject: [PATCH 1/3] chore: execute build runner --- .../integration_test/gherkin_suite_test.dart | 1 + .../gherkin_suite_test.g.dart | 206 +++++++++--------- .../ios/Flutter/Debug.xcconfig | 1 + .../ios/Flutter/Release.xcconfig | 1 + example_with_integration_test/ios/Podfile | 41 ++++ example_with_integration_test/pubspec.lock | 34 +-- pubspec.lock | 41 ++-- 7 files changed, 181 insertions(+), 144 deletions(-) create mode 100644 example_with_integration_test/ios/Podfile diff --git a/example_with_integration_test/integration_test/gherkin_suite_test.dart b/example_with_integration_test/integration_test/gherkin_suite_test.dart index e3e9fb9..7a60267 100644 --- a/example_with_integration_test/integration_test/gherkin_suite_test.dart +++ b/example_with_integration_test/integration_test/gherkin_suite_test.dart @@ -8,6 +8,7 @@ part 'gherkin_suite_test.g.dart'; @GherkinTestSuite( useAbsolutePaths: false, + executionOrder: ExecutionOrder.sequential ) void main() { executeTestSuite( diff --git a/example_with_integration_test/integration_test/gherkin_suite_test.g.dart b/example_with_integration_test/integration_test/gherkin_suite_test.g.dart index 2390853..76b5d80 100644 --- a/example_with_integration_test/integration_test/gherkin_suite_test.g.dart +++ b/example_with_integration_test/integration_test/gherkin_suite_test.g.dart @@ -38,7 +38,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { runScenario( name: 'User can create single todo item', description: null, - path: '.\\integration_test\\features\\create.feature', + path: './integration_test/features/create.feature', tags: ['@tag'], steps: [ ( @@ -92,7 +92,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ], onBefore: () async => onBeforeRunFeature( name: 'Creating todos', - path: '.\\integration_test\\features\\create.feature', + path: './integration_test/features/create.feature', description: null, tags: ['@tag'], ), @@ -101,8 +101,8 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { runScenario( name: 'User can create multiple new todo items', description: null, - path: '.\\integration_test\\features\\create.feature', - tags: ['@tag', '@debug2'], + path: './integration_test/features/create.feature', + tags: ['@tag'], steps: [ ( TestDependencies dependencies, @@ -242,7 +242,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ], onAfter: () async => onAfterRunFeature( name: 'Creating todos', - path: '.\\integration_test\\features\\create.feature', + path: './integration_test/features/create.feature', description: null, tags: ['@tag'], ), @@ -252,73 +252,6 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { } void testFeature1() { - runFeature( - name: 'Checking data:', - tags: ['@tag'], - run: () { - runScenario( - name: 'User can have data', - description: null, - path: '.\\integration_test\\features\\check.feature', - tags: ['@tag', '@tag1'], - steps: [ - ( - TestDependencies dependencies, - bool skip, - ) async { - return await runStep( - name: 'Given I have item with data', - multiLineStrings: [ - """{ - "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: '.\\integration_test\\features\\check.feature', - description: null, - tags: ['@tag'], - ), - onAfter: () async => onAfterRunFeature( - name: 'Checking data', - path: '.\\integration_test\\features\\check.feature', - description: null, - tags: ['@tag'], - ), - ); - }, - ); - } - - void testFeature2() { runFeature( name: 'Swiping:', tags: ['@tag'], @@ -326,7 +259,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { runScenario( name: 'User can swipe cards left and right', description: null, - path: '.\\integration_test\\features\\swiping.feature', + path: './integration_test/features/swiping.feature', tags: ['@tag'], steps: [ ( @@ -382,13 +315,13 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ], onBefore: () async => onBeforeRunFeature( name: 'Swiping', - path: '.\\integration_test\\features\\swiping.feature', + path: './integration_test/features/swiping.feature', description: null, tags: ['@tag'], ), onAfter: () async => onAfterRunFeature( name: 'Swiping', - path: '.\\integration_test\\features\\swiping.feature', + path: './integration_test/features/swiping.feature', description: null, tags: ['@tag'], ), @@ -397,24 +330,50 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ); } - void testFeature3() { + void testFeature2() { runFeature( - name: 'Parsing:', - tags: ['@debug'], + name: 'Checking data:', + tags: ['@tag'], run: () { runScenario( - name: 'Parsing a', + name: 'User can have data', description: null, - path: '.\\integration_test\\features\\parsing.feature', - tags: ['@debug'], + path: './integration_test/features/check.feature', + tags: ['@tag', '@tag1'], steps: [ ( TestDependencies dependencies, bool skip, ) async { return await runStep( - name: 'Given the text "^[A-Z]{3}\\\\d{5}\\\$"', - multiLineStrings: [], + name: 'Given I have item with data', + multiLineStrings: [ + """{ + "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, @@ -422,29 +381,23 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { }, ], onBefore: () async => onBeforeRunFeature( - name: 'Parsing', - path: '.\\integration_test\\features\\parsing.feature', - description: """Complex description: -- Line "one". -- Line two, more text -- Line three""", - tags: ['@debug'], + name: 'Checking data', + path: './integration_test/features/check.feature', + description: null, + tags: ['@tag'], ), onAfter: () async => onAfterRunFeature( - name: 'Parsing', - path: '.\\integration_test\\features\\parsing.feature', - description: """Complex description: -- Line "one". -- Line two, more text -- Line three""", - tags: ['@debug'], + name: 'Checking data', + path: './integration_test/features/check.feature', + description: null, + tags: ['@tag'], ), ); }, ); } - void testFeature4() { + void testFeature3() { runFeature( name: 'Expect failures:', tags: [], @@ -452,7 +405,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { runScenario( name: 'Exception should be added to json report', description: null, - path: '.\\integration_test\\features\\failure.feature', + path: './integration_test/features/failure.feature', tags: ['@failure-expected'], steps: [ ( @@ -471,7 +424,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ], onBefore: () async => onBeforeRunFeature( name: 'Expect failures', - path: '.\\integration_test\\features\\failure.feature', + path: './integration_test/features/failure.feature', description: """Ensure that when a test fails the exception or test failure is reported""", tags: [], @@ -481,7 +434,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { runScenario( name: 'Failed expect() should be added to json report', description: "Description for this scenario!", - path: '.\\integration_test\\features\\failure.feature', + path: './integration_test/features/failure.feature', tags: ['@failure-expected'], steps: [ ( @@ -523,7 +476,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { ], onAfter: () async => onAfterRunFeature( name: 'Expect failures', - path: '.\\integration_test\\features\\failure.feature', + path: './integration_test/features/failure.feature', description: """Ensure that when a test fails the exception or test failure is reported""", tags: [], @@ -532,12 +485,59 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { }, ); } + + void testFeature4() { + runFeature( + name: 'Parsing:', + tags: ['@debug'], + run: () { + runScenario( + name: 'Parsing a', + description: null, + path: './integration_test/features/parsing.feature', + tags: ['@debug'], + steps: [ + ( + TestDependencies dependencies, + bool skip, + ) async { + return await runStep( + name: 'Given the text "^[A-Z]{3}\\\\d{5}\\\$"', + multiLineStrings: [], + table: null, + dependencies: dependencies, + skip: skip, + ); + }, + ], + onBefore: () async => onBeforeRunFeature( + name: 'Parsing', + path: './integration_test/features/parsing.feature', + description: """Complex description: +- Line "one". +- Line two, more text +- Line three""", + tags: ['@debug'], + ), + onAfter: () async => onAfterRunFeature( + name: 'Parsing', + path: './integration_test/features/parsing.feature', + description: """Complex description: +- Line "one". +- Line two, more text +- Line three""", + tags: ['@debug'], + ), + ); + }, + ); + } } void executeTestSuite({ required FlutterTestConfiguration configuration, required StartAppFn appMainFunction, - Timeout scenarioExecutionTimeout = const Timeout(Duration(minutes: 10)), + Timeout scenarioExecutionTimeout = const Timeout(const Duration(minutes: 10)), AppLifecyclePumpHandlerFn? appLifecyclePumpHandler, LiveTestWidgetsFlutterBindingFramePolicy? framePolicy, }) { diff --git a/example_with_integration_test/ios/Flutter/Debug.xcconfig b/example_with_integration_test/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example_with_integration_test/ios/Flutter/Debug.xcconfig +++ b/example_with_integration_test/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example_with_integration_test/ios/Flutter/Release.xcconfig b/example_with_integration_test/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example_with_integration_test/ios/Flutter/Release.xcconfig +++ b/example_with_integration_test/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example_with_integration_test/ios/Podfile b/example_with_integration_test/ios/Podfile new file mode 100644 index 0000000..88359b2 --- /dev/null +++ b/example_with_integration_test/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example_with_integration_test/pubspec.lock b/example_with_integration_test/pubspec.lock index 08a0802..b19e65a 100644 --- a/example_with_integration_test/pubspec.lock +++ b/example_with_integration_test/pubspec.lock @@ -21,7 +21,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.11" + version: "3.3.0" args: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -133,7 +133,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: @@ -161,7 +161,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" dart_style: dependency: transitive description: @@ -175,7 +175,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -324,21 +324,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mime: dependency: transitive description: @@ -359,7 +359,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_provider_linux: dependency: transitive description: @@ -511,7 +511,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -539,28 +539,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" sync_http: dependency: transitive description: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" timing: dependency: transitive description: @@ -574,7 +574,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" uuid: dependency: "direct main" description: @@ -595,7 +595,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "8.2.2" + version: "9.0.0" watcher: dependency: transitive description: diff --git a/pubspec.lock b/pubspec.lock index 66577f3..7e26120 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -35,7 +35,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.11" + version: "3.3.0" args: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -77,14 +77,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" checked_yaml: dependency: transitive description: @@ -98,7 +91,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: "direct main" description: @@ -119,7 +112,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" csslib: dependency: transitive description: @@ -147,7 +140,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" file: dependency: transitive description: @@ -235,21 +228,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: "direct dev" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_config: dependency: transitive description: @@ -263,7 +256,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" pedantic: dependency: "direct dev" description: @@ -324,7 +317,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -345,35 +338,35 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" sync_http: dependency: transitive description: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" uuid: dependency: transitive description: @@ -394,7 +387,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "8.2.2" + version: "9.0.0" watcher: dependency: transitive description: From d087a8c377cc3936000d5ec9dbbedb2588d230f9 Mon Sep 17 00:00:00 2001 From: August Oberhauser Date: Mon, 14 Nov 2022 15:35:13 +0100 Subject: [PATCH 2/3] fix: avoid allowing to pass, if scenario failed --- lib/src/flutter/runners/gherkin_integration_test_runner.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/flutter/runners/gherkin_integration_test_runner.dart b/lib/src/flutter/runners/gherkin_integration_test_runner.dart index 78f59ef..e03a75f 100644 --- a/lib/src/flutter/runners/gherkin_integration_test_runner.dart +++ b/lib/src/flutter/runners/gherkin_integration_test_runner.dart @@ -261,6 +261,7 @@ abstract class GherkinIntegrationTestRunner { ); await cleanUpScenarioRun(dependencies); + expect(failed, false); } }, timeout: scenarioExecutionTimeout, From 8033abb2e1cadf873885564b4b692b3ac6236ca6 Mon Sep 17 00:00:00 2001 From: August Oberhauser Date: Thu, 29 Dec 2022 16:10:34 +0100 Subject: [PATCH 3/3] fix: remove bracket on gherkin generator --- .../generators/gherkin_suite_test_generator.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart b/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart index fe09cf8..42d8e9c 100644 --- a/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart +++ b/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart @@ -59,13 +59,12 @@ Future executeTestSuite({ LiveTestWidgetsFlutterBindingFramePolicy? framePolicy, }) => _CustomGherkinIntegrationTestRunner( - configuration: configuration, - appMainFunction: appMainFunction, - appLifecyclePumpHandler: appLifecyclePumpHandler, - scenarioExecutionTimeout: scenarioExecutionTimeout, - framePolicy: framePolicy, - ).run(); -} + configuration: configuration, + appMainFunction: appMainFunction, + appLifecyclePumpHandler: appLifecyclePumpHandler, + scenarioExecutionTimeout: scenarioExecutionTimeout, + framePolicy: framePolicy, + ).run(); '''; final _reporter = NoOpReporter(); final _languageService = LanguageService();