Git Product home page Git Product logo

dart_gherkin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dart_gherkin's Issues

doc for running example

I'm a newbie using Dart 2.13.0 on Mac OS.

I downloaded the zip file, unzipped it, and tried:

cd example
dart test.dart

and received import errors. So I tried this (the first part does install dependencies):

cd ..
dart test
cd example
dart test.dart

and receive this:

before run hook
0 scenario ()
0 step ()
0:00:00.001000
after run hook

However, if I intentionally put a wrong expected-result in ./features/calculator_can_add.feature, the test doesn't fail. So it appears that the features aren't being picked up. What am I doing wrong? I believe I'm following the documentation.

Multiline strings to support YAML format

I have a use case where I would like to pass YAML in a multiline string and it would be converted to JSON (YAML is used for simplicity to write it).
Example:

@multilineYaml
Feature: Multiline string YAML example
  Scenario: YAML scenario
    Given I can convert YAML to JSON structure
  """
  - name: YAML test
    type: simple_convertion
    value: 100
    conditions:
      - type: convertion
        value: Convertion value
  """

After multiline has been read, YAML is modified and the output now looks like this and from here it can't be correctly read with Dart:

- name: YAML test
type: simple_convertion
value: 100
conditions:
- type: convertion
value: Convertion value

Point of code to check:

lines.add((child as TextLineRunnable).text);

&&

https://github.com/jonsamwell/dart_gherkin/blob/master/lib/src/gherkin/syntax/text_line_syntax.dart#L25

I was wondering if it's possible to put a flag or member property that would not perform trimming?

Null-Safety

Hi,
thanks for the great library!
Do you have any plans for supporting the new null-safety feature? I started to migrate my own package to null-safety which uses gherkin as a dev_dependency. Since gherkin is not migrated yet, I have to use --no-sound-null-safety flag when running tests. It makes debugging the tests difficult because I am not able to pass this flag to the VSCode launch.json or to the Debug|Run buttons in the IDE. The workaround is to put // @dart=2.9 comment at the top of the test entry point.
It is no big deal since it is just dev_dependency which is not blocking the actual null-safety migration, but it would be nice to have sound null safety eventually.

Parser fails to parse certain Gherkin multiline strings that start with an asterisk

The dart_gherkin parser fails to parse certain multiline strings.

The following scenario works (using x):

Feature: Conway's Game of Life

  Scenario: Single cell universe
    Given the following universe:
    """
    x
    """

The following scenario fails (using *):

Feature: Conway's Game of Life

  Scenario: Single cell universe
    Given the following universe:
    """
    *
    """

Stacktrace:

Error while parsing feature file: './features/GameOfLife.feature'
Instance of 'GherkinSyntaxException'
package:gherkin/src/gherkin/parser.dart 122:9                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 55:7                            GherkinParser.parseFeatureFile
===== asynchronous gap ===========================
package:gherkin/src/test_runner.dart 47:43                              GherkinRunner.execute
===== asynchronous gap ===========================
test/acceptance_test.dart 11:26                                         main
===== asynchronous gap ===========================
package:test_api                                                        RemoteListener.start
package:test_core/src/runner/plugin/remote_platform_helpers.dart 35:20  serializeSuite
data:... 11:21                                                          main

Failed to load "/home/christian.hujer/git/nelkinda/gameoflife-dart/test/acceptance_test.dart": Instance of 'GherkinSyntaxException'

Failing a step in a `onAfterStep` hook

Hi! First of all thank you for maintaining this library, I know how hard it is to do work in open-source. I appreciate it!

Context

We are using this package to run custom contract tests. We are using the gherkin runner as one of the parts of the whole testing structure.

Currently we are on a roadblock: after each step in a scenario we need to confirm that the contract is being upheld, and in case the contract is broken we need to fail the step (even if the step executed successfully). One way we can implement it is to add an expect assertion in each step definition, but that can be troublesome because 1. we need to repeat this in each step, 2. forgetting to add this the definition can give way to bugs.

Fortunately the cucumber standard has hooks that seem to do fill this void perfectly.

However, in this package, there is no way to influence the "result" of a step in the onAfterStep hook, so the only option is to throw. But throwing interrupts the execution of the step, so reporter is not being called and the exception is propagated upwards.

Question

Would it be desirable to add a feature where the result of a step can be failed in a hook (and that causes the rest of the steps to be skipped and properly reported)?

I can definitely submit a proof of concept PR. Let me know if that is something thats worth pursuing for this library in general.

type '_TypeError' is not a subtype of type 'Exception'

Hello,

I was running a test and an error happened in the app. However instead of failing the test, the process finished instead.

[warning] FlutterDriver: tap message is taking a long time to complete...
6 scenarios (3 passed, 3 failed)
6 steps (3 passed, 3 failed)
0:03:30.384000
Unhandled exception:
type '_TypeError' is not a subtype of type 'Exception'
#0 FeatureFileRunner._runFeature (package:gherkin/src/feature_file_runner.dart:53:37)

#1 FeatureFileRunner.run (package:gherkin/src/feature_file_runner.dart:32:38)

#2 GherkinRunner.execute (package:gherkin/src/test_runner.dart:73:45)

#3 main (file:///Users/abanv2/Documents/Bitbucket/janus-mobile-app/test_driver/main_page_test.dart:24:26)
#4 _startIsolate. (dart:isolate-patch/isolate_patch.dart:300:19)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)

Process finished with exit code 255

Is it possible to just have this as a test failure instead of the entire process crashing?
Thank you.

background can't have empty line

It's not allowed empty line in background section, it will through errors "Exception: Unknown runnable child given to Feature 'StepRunnable' - Line#And they are added"
image

Support Gherkin Feature/Scenario descriptions

Hi! I've been using this package to run and generate reports for my gherkin tests. I noticed that the description lines are either ignored (feature description) or treated as a syntax error (scenario description) by flutter_gherkin. I'm using JsonReporter to generate test report json files, that I then convert to HTML reports, but it seems that the description fields in JsonFeature and JsonScenario classes are hardcoded to always be empty strings.

Are there any plans to support handling descriptions? If not, are there any workarounds I could use, to automatically include descriptions in my reports?

Interpolate scenario outline names

Hi,

I was playing around with gherkin, in particular with scenario outlines and tagging a set of examples.
Suppose I've got a scenario outline like:

  Scenario Outline: The user clicks <n> times.
    Given The counter shows a count of 0
    When The user clicks <n> times
    Then The counter shows a count of <n>
  @smoke
  Examples:
    | n  |
    | 0  |
    | 1  |
  Examples:
    | n  |
    | 42 |

When parsing this outline, the scenarios get the following names:

Example Name
0 The user clicks times. Examples: (1)
1 The user clicks times. Examples: (2)
42 The user clicks times. Examples: (1)

To me this is confusing, I would have expected the n variable to be interpolated in the scenario name as well. (In particular, my build server is unable to differentiate between the 0 and 42 examples. I would have expected something along the lines of:

Example Name
0 The user clicks 0 times. Examples: (1)
1 The user clicks 1 times. Examples: (2)
42 The user clicks 42 times. Examples: (1)

Would you be open to a pull request that adds this interpolation?

Parser fails on comment strings that start with `>`

The dart_gherkin parser fails to parse certain comment strings.

The following scenario works:

Feature: Conway's Game of Life

  Rules of Conway's Game of Life
  The universe of the _Game of Life_ is an infinite, two-dimensional orthogonal grid of square cells.

  Scenario: Empty universe
    Given the following universe:
    """
    """

The following scenario fails:

Feature: Conway's Game of Life

  Rules of Conway's Game of Life
  > The universe of the _Game of Life_ is an infinite, two-dimensional orthogonal grid of square cells.

  Scenario: Empty universe
    Given the following universe:
    """
    """

Stacktrace:

Error while parsing feature file: './features/GameOfLife.feature'
Instance of 'GherkinSyntaxException'
package:gherkin/src/gherkin/parser.dart 122:9                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 55:7                            GherkinParser.parseFeatureFile
===== asynchronous gap ===========================
package:gherkin/src/test_runner.dart 47:43                              GherkinRunner.execute
===== asynchronous gap ===========================
test/acceptance_test.dart 11:26                                         main
===== asynchronous gap ===========================
package:test_api                                                        RemoteListener.start
package:test_core/src/runner/plugin/remote_platform_helpers.dart 35:20  serializeSuite
data:... 11:21                                                          main

Failed to load "/home/christian.hujer/git/nelkinda/gameoflife-dart/test/acceptance_test.dart": Instance of 'GherkinSyntaxException'

Tags not supported

Trying to use this with jira/xray cucumber tests but are having a problem with tags and generated reports.

Doesn't like the tag on Feature (throws exception) and tags on Scenario are not included in generated report.

Could this be added?

@a
Feature: One passing scenario, one failing scenario

  @b
  Scenario: Passing
    Given this step passes

  @c
  Scenario: Failing
    Given this step fails

Format of cucumber .feature file exported from jira/xray

[ #language: { language } ]
[ @{ Test Execution issue Key } ]
[ @{ Requirement issue Key } ]
Feature: [{ Requirement Issue Summary }]
    [{ Requirement Issue Description }]
     
    [Background: 
        { Pre-Conditions }]
     
    [# { Test Issue Description }]
    @{ Test Issue Key } 
    [@{ SubRequirement Issue Key 1 } ... @{ SubRequirement Issue Key N }] 
    [@{ Test Set Issue Key 1 } ... @{ Test Set Issue Key N }] 
    [@{ Test Issue Label 1 } ... @{ Test Issue Label N}]
    Scenario [Outline]: { Test Issue Summary }
        {Test Issue Steps}

Reference
https://relishapp.com/cucumber/cucumber/docs/formatters/json-output-formatter

Implement widget testing?

Hi, I would like to ask on how do I implement widget testing with this package.

Normal ways is to run with:

testWidgets('scenarios', (WidgetTester tester) async {
    await tester.pumpWidget(WidgetToBeTested());
});

Unable to use library with Dart Web tests

Hi,

Thank you for creating the gherkin package.

As the repository title states, the library provides the base BDD functionality ready for use in platform specific implementations i.e. flutter/web. In a flutter app, feature tests works seamlessly. We just can't run any web tests (i.e. Angular Dart) because of the following dependencies:

  • dart:io
  • glob

Both packages are not supported on the web (related issue: flutter/flutter#39998) so test scripts won't compile.

Is there any way to overcome the issues? Is there any example of a web tests usage? Or is the library intended to use only with "driver" (detached) tests?

Example:

Given a test (just import, without any usage):

@TestOn('browser')

import 'package:angular_test/angular_test.dart';
import 'package:pageloader/html.dart';
import 'package:test/test.dart';
import 'package:app_angular/app.template.dart' as ng;
import 'package:app_angular/app.dart';
import 'package:gherkin/gherkin.dart';

// Running tests:
// pub run build_runner test --fail-on-severe -- -p chrome
void main() {
  final testBed = NgTestBed.forComponent<App>(ng.AppNgFactory);
  NgTestFixture<App> fixture;
  HtmlPageLoaderElement context;

  setUp(() async {
    fixture = await testBed.create();
    context = HtmlPageLoaderElement.createFromElement(fixture.rootElement);
  });

  tearDown(disposeAnyRunningTest);

  test('Default greeting', () {
    expect(
      context.createElement(ByTagName('h1'), [], []).visibleText,
      "My header",
    );
}

Causes a dependency warning and compilation failure:

[WARNING] build_web_compilers:entrypoint on test/app_test.dart.browser_test.dart:
Skipping compiling app_angular|test/app_test.dart.browser_test.dart with ddc because some of its
transitive libraries have sdk dependencies that not supported on this platform:

gherkin|lib/src/test_runner.dart
gherkin|lib/src/reporters/stdout_reporter.dart
gherkin|lib/src/reporters/json/json_reporter.dart
glob|lib/src/io_export.dart

https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

[INFO] Running build completed, took 12.1s
[INFO] Caching finalized dependency graph completed, took 204ms
[INFO] Creating merged output dir `/var/folders/tg/lkd3kcrj6x1_4btn7fst1g0h0000gn/T/build_runner_testTQvcSi/` completed, took 806ms
[INFO] Writing asset manifest completed, took 5ms
[INFO] Succeeded after 13.2s with 2474 outputs (7510 actions)
Running tests...

00:01 +0 -1: compiling test/app_test.dart [E]                                                                                                  
  Failed to load "test/app_test.dart": Failed to load script at http://localhost:56355/MGEFr%2FDxp5pD43tGbJTz1fDSDZAthgjh/test/app_test.dart.browser_test.dart.js.
00:01 +0 -1: Some tests failed.   

Commenting the import 'package:gherkin/gherkin.dart' line fixes the issue:

[INFO] Generating build script completed, took 378ms
[INFO] Reading cached asset graph completed, took 297ms
[INFO] Checking for updates since last build completed, took 991ms
[INFO] Running build completed, took 11.7s
[INFO] Caching finalized dependency graph completed, took 172ms
[INFO] Creating merged output dir `/var/folders/tg/lkd3kcrj6x1_4btn7fst1g0h0000gn/T/build_runner_testjhLypD/` completed, took 802ms
[INFO] Writing asset manifest completed, took 20ms
[INFO] Succeeded after 12.7s with 324 outputs (330 actions)
Running tests...

00:01 +0: test/app_test.dart: Default greeting                                                                                                 
00:02 +1: All tests passed!  

Missing classes

Hi, I've just cloned the example flutter-driver-demo, but there are some classes unreachable.
Like:

  • Given1WithWorld
  • StepDefinitionConfiguration

image

Tags are not taking into account after an `Example` block

In the case given bellow the skip tag is not apply to the second scenario.

Feature: Bug example
  This is the minimal example to reproduce the bug

  Scenario Outline: Should run
    Given the characters "<characters>"
    When they are counted
    Then the expected result is <result>

    Examples:
      | characters | result |
      | abc        | 294    |

  @skip
  Scenario: Should not run (but does)
    Given the characters "abc"
    When they are counted
    Then the expected result is 294

Note that the following works properly:

Feature: Tags working properlly
  Show that the problem is only encountered after Example block

  Scenario: Should run
    Given the characters "abc"
    When they are counted
    Then the expected result is 294

  @skip
  Scenario: Should not run
    Given the characters "abc"
    When they are counted
    Then the expected result is 294

Why do {word} parameters have to be surrounded by quotes?

Using an example in the README, I have a step definition like Given I eat a {word}, which would match Given I eat a "worm" or Given I eat a 'worm'. But it doesn't match Given I eat a worm.

When using {int}s, {num}s and {float}s, it is not necessary to surround the values with quotes. Would it be possible to extend the same functionality to {word}? (but not {string})

Expose JsonReporter for extension

Hello,

Currently, the JsonReporter can be used as it is provided by the package. But, it is complicated to extend its functionnality or change its behavior because JsonReporter depends on classes that are not visible outside the package:
https://github.com/jonsamwell/dart_gherkin/tree/master/lib/src/reporters/json

For the package users, the only way to override the behavior of JsonReporter is to "copy paste" all its dependencies.

Will it be possible to expose publicly the folders containing the JsonReporter dependencies ?

Thank you

Feature files not retrieved when they are not within or aside working directory

Hi,

We are using same feature files for several testing frameworks including dart_gherkins so those files are on a different level than the dart working directory :

- marvelous-project/
        - features/
              - peanut.feature
              - banana.feature
        - dart_testing_fwk_folder
              - dart/
                    - test/
                    - ...
                    - pubspec.yml
        - another_testing_fwk
        - agin_another_testing_fwk

We set the following TestConfiguration:

return TestConfiguration()
    ..features = [Glob( '*.feature')]
    ..featureFileMatcher = IoFeatureFileAccessor(
        workingDirectory: Directory(Directory.current.path + "/../../features"))
    ..featureFileReader = IoFeatureFileAccessor(
        workingDirectory: Directory(Directory.current.path + "/../../features"))

We validated the current directory is dart and not testso the path from dart to features folder is correct.

After investigation, we found out that only the relative path of files matching the featureFileMatcher was stored :

Future<List<String>> _directoryContents(
    Directory directory,
    Pattern pattern,
  ) async {
    [...]
          final match = pattern.matchAsPrefix(relativePath);
          if (match?.group(0) == relativePath) {
            result.add(relativePath);
          }
    [...]
    return result;
  }

So only peanut.feature was returned and not its full path.

I've tried to modify this little line like this and it resolved my issue :

Future<List<String>> _directoryContents(
    Directory directory,
    Pattern pattern,
  ) async {
    [...]
          final match = pattern.matchAsPrefix(relativePath);
          if (match?.group(0) == relativePath) {
            result.add(item.path);
          }
    [...]
    return result;
  }

I've opened a pull request to fix this point :).
Thank you!

Parser fails on empty lines in multiline strings

The dart_gherkin parser fails to parse multiline strings that contain empty lines.

The following scenario fails (note the empty lines within the multiline string):

Feature: Conway's Game of Life

  Scenario: Blinker
    Given the following universe:
    """

    xxx

    """

Stacktrace:

Error while parsing feature file: './features/GameOfLife.feature'
Instance of 'GherkinSyntaxException'
package:gherkin/src/gherkin/syntax/multiline_string_syntax.dart 30:7    MultilineStringSyntax.hasBlockEnded
package:gherkin/src/gherkin/parser.dart 89:31                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 109:15                          GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 55:7                            GherkinParser.parseFeatureFile
===== asynchronous gap ===========================
package:gherkin/src/test_runner.dart 47:43                              GherkinRunner.execute
===== asynchronous gap ===========================
test/acceptance_test.dart 11:26                                         main
===== asynchronous gap ===========================
package:test_api                                                        RemoteListener.start
package:test_core/src/runner/plugin/remote_platform_helpers.dart 35:20  serializeSuite
data:... 11:21                                                          main

Failed to load "/home/christian.hujer/git/nelkinda/gameoflife-dart/test/acceptance_test.dart": Instance of 'GherkinSyntaxException'

Allow async operation for CustomParameter

Hello,

Currently, we can define CustomParameter using a callback that transformes steps parameters. This work well with synchronous callbacks.

Problem
We can't evaluate parameters using an asynchronous callback without returning a Future.

Let's take the following use case: We have certain step parameters that should be evaluated using an API or any asynchronous opration. The result of the transformed parameter is of type Future<T>.

Ideally, it would be great if we can do something like this and return T instead of Future<T>:

class CustomString extends CustomParameter<String> {
  CustomString()
      : super(
    'custom_string',
    RegExp(r'"(.*?)"', dotAll: true),
        (String input) async {
      if (input.startsWith(r"$")) {
        // Evaluate the parameter using some API or an async operation
        return await _callAPI(input);
      }
        
      return input;
    },
  );

  static Future<String> _callAPI(String input) => Future.value(input);
}

Currently, we're forced to return Future<String> and to wait that string to be returned in the step definition (this means that the step definition is taking a Future or a FutureOr as a parameter).

Do you think that this feature should be supported ?

Thank you

Multiline text can't contain lines that have a keyword prefix

Example:

Feature: Multiline text example

Scenario: Contain a line with keyword prefix
    Given I have a feature:
    '''
    Feature: Multiline text has a line with keyword prefix
    Scenario: test case
        Given some step
        Then some result
    '''

Outputs:

[SEVERE] flutter_gherkin:gherkin_test_suite on integration_test/gherkin_suite_test.dart:

Instance of 'GherkinSyntaxException'
package:gherkin/src/gherkin/syntax/multiline_string_syntax.dart 33:7                                     MultilineStringSyntax.hasBlockEnded
package:gherkin/src/gherkin/parser.dart 114:31                                                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 136:15                                                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 136:15                                                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 136:15                                                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 136:15                                                           GherkinParser._parseBlock
package:gherkin/src/gherkin/parser.dart 68:7                                                             GherkinParser.parseFeatureFile
package:gherkin/src/gherkin/ast/feature_file_visitor.dart 13:25                                          FeatureFileVisitor.visit
package:flutter_gherkin/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart 165:5   FeatureFileTestGeneratorVisitor.generateTests
package:flutter_gherkin/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart 110:12  FeatureFileTestGenerator.generate
package:flutter_gherkin/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart 76:20   GherkinSuiteTestGenerator.generateForAnnotatedElement
...

Scenario Outline Support?

Does the library support Scenario Outline? I can't seem to get it to work. I get the following error:
Unknown runnable child given to Feature 'StepRunnable'.

Step with less input parameters incorrectly used

Currently having an issue where the wrong step is selected when I'm trying to run my gherkin tests.

Steps

I have two And steps for my gherkin tests:

  1. shop {string} provided a shop log on {word} at UTC time {string}

  2. shop {string} provided a shop log on {word}

Gherkin Test

Scenario 1

Whenever I run my gherkin tests which has the following:

And the shop "Gherkin Shop" provided a shop log on "Friday" at UTC time "01:00:00"

The selected step is the second one instead of the first one.

Scenario 2

Whereas if I have the following And step

the shop "Gherkin Shop" provided a shop log on "Friday"

Then the only step which matches is 'shop {string} provided a shop log on {word}'

What's causing this

I went ahead and inspected the code which determines the step selection and found this located in feature_file_runner.dart.

final executable = _steps.firstWhereOrNull(
      (s) => s.expression.isMatch(step.debug.lineText),
);

Potential solution

If we use this line of code instead, we can see that in the first Gherkin test scenario there would be 2 matching results.

_steps.where((s) => s.expression.isMatch(step.debug.lineText)).toList()

If we extend the accessibility of the _expectParameterCount variable for StepDefinitionGeneric so there's a getter within ExecutableStep, then we could check which step has more steps and always opt to using that step over the rest.

If they have the same number of steps, we could resort to the default behaviour of taking the first match.

Temporary solution

I can reword the step to make it more unique which is fine for now but not ideal and it'd be nicer if this improvement can be made for a future version 🤞

Example not working properly

When I try to run the example following the ReadMe instructions I end up getting this return in the terminal:

0 scenario ()
0 step ()
0:00:00.000000
after run hook

What am I doing wrong?

Test fails for scenarios using data tables with null values

Hello,

This issue concerns packages relying on dart_gherkin (such as flutter_gherkin) because they can use the factory constructor GherkinTable.fromJson.

The bug is that the test fails when it encounters a null value in a data table. And, the error that is thrown is the following:

I/flutter (20164): Exception: type 'Null' is not a subtype of type 'String' in type cast
I/flutter (20164): #0      CastIterator.current (dart:_internal/cast.dart:62:36)
I/flutter (20164): #1      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:36)
I/flutter (20164): #2      new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
I/flutter (20164): #3      new List.of (dart:core-patch/array_patch.dart:51:28)
I/flutter (20164): #4      Iterable.toList (dart:core/iterable.dart:470:12)
I/flutter (20164): #5      GherkinTable.asMap.<anonymous closure> (package:gherkin/src/gherkin/models/table.dart:35:30)
I/flutter (20164): #6      MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
I/flutter (20164): #7      ListIterator.moveNext (dart:_internal/iterable.dart:342:26)

To fix this issue, the cast should be to String? instead of String :

.map((x) => TableRow(x.values.cast<String>(), 1, isHeaderRow: false));

Here is a simple project to reproduce the bug using flutter_gherkin3-rc16: https://github.com/youssef-t/basic-flutter-app-with-flutter-gherkin.

Thank you

Generify World in Hook Class

I propose to generify the methods that use the World objects in the Hook class such as:

  Future<void> onAfterScenarioWorldCreated(
    World world,
    String scenario,
    Iterable<Tag> tags,
  ) =>

And use something like:

class Hook<T extends World> {
  Future<void> onAfterScenarioWorldCreated(
      T world,
      String scenario,
      Iterable<Tag> tags,
      ) async {
    // Your implementation here
  }
}

This way we can use our own instances of World

// Define the subclass that overrides the method
class MyHook extends Hook<MyWorld> {
  @override
  Future<void> onAfterScenarioWorldCreated(
      MyWorld world,
      String scenario,
      Iterable<Tag> tags,
      ) async {
    // Your implementation here
  }
}

Add World to "onAfterScenario" Hook

I am running puppeteer automation with gherkin and I am unable to properly open the browser at the beginning of my scenario and then close it at the end.

The problem is that the onAfterScenario hook does not have access to the world object where I store my Browser object.
Is it possible to add it ?

Scenario Outline & Scenario in same feature file

The library throws an exception when running a Scenario Outline and Scenario in the same file.

Unhandled exception: Exception: Unknown runnable child given to Scenario 'ScenarioRunnable' #0 ScenarioRunnable.addChild (package:gherkin/src/gherkin/runnables/scenario.dart:33:9) #1 ScenarioOutlineRunnable.addChild (package:gherkin/src/gherkin/runnables/scenario_outline.dart:28:15) #2 GherkinParser._parseBlock (package:gherkin/src/gherkin/parser.dart:119:21) #3 GherkinParser._parseBlock (package:gherkin/src/gherkin/parser.dart:108:15) #4 GherkinParser._parseBlock (package:gherkin/src/gherkin/parser.dart:108:15) #5 GherkinParser.parseFeatureFile (package:gherkin/src/gherkin/parser.dart:55:7) <asynchronous suspension> #6 GherkinRunner.execute (package:gherkin/src/test_runner.dart:47:43) <asynchronous suspension> #7 main (file:///.../app_test.dart:37:26) #8 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19) #9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Custom parameter for type List<int> is causing RangeError exception

Exception

Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5
Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5
Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5

Custom parameter definition

class ListIntParameter extends CustomParameter<List<int>> {
  ListIntParameter()
      : super('listInt', RegExp(r'(\[(\d+(\,\d)*)*\]){1}', caseSensitive: false), (value) {
          print('1 - aqui:'+value);
          final result = value.replaceAll(RegExp(r'\[|\]'), '').split(',')
              .map(
                (e) => int.tryParse(e),
          )
              .whereNotNull()
              .toList(
            growable: false,
          );
          print(result);
          return result;
        });
}

Step definition

class GivenUserEntersTheInformations extends Given5WithWorld<String, String,
    String, List<int>, String, MyWorld> {
  @override
  Future<void> executeStep(
    String primaryPosition,
    String secondaryPosition,
    String preferredFieldSide,
    List<int> skillsIds,
    String favoriteFoot,
  ) async {
    // TODO: implement executeStep
    throw UnimplementedError();
  }

  @override
  Pattern get pattern => RegExp(
        r'User enters the informations {string}, {string}, {string}, {listInt}, {string}',
      );
}

French keyword "Lorsqu'il" makes parser crash

Hi!
We write our gherkin scenarios in full french - keywords included - and we spotted that the keyword Lorsqu' makes the parser crash with this error: Unknown runnable child given to Scenario 'TextLineRunnable'

When we replace it with Lorsque il, everything works fine. Example below:
Capture d’écran 2021-02-26 à 18 14 11
Capture d’écran 2021-02-26 à 18 14 35

We set up the featureDefaultLanguage to fr and nothing changed. We checked that this word was a part of the gherkin dictionary and so it is: https://raw.githubusercontent.com/cucumber/cucumber/80b282783dca20bbf3d32a8dd6c85abccf5bd70c/gherkin/gherkin-languages.json

For the meantime we will use "Lorsque il" instead of "Lorsqu'il" but it would be great if we could use this keyword 😃.

I tried to dive into the code to find out why this keyword causes error (I'm not very at my ease with dart but maybe it can help you) and I found that steps seem to be parsed twice, and at the second round, the line Lorsqu'il va acheter sa baguette is not considered as a RunnableBlock. Indeed condition runnable is RunnableBlock is false with the use of Lorsqu' keyword and true when we use Lorsque keyword. So, instead of continue parsing the feature file with _parseBlock() method, program jumps directly to parentBlock.addChild(runnable) and this jump raises an error.

I used your example repo to illustrate my issue 😄: https://github.com/kchiron/french_example. You can directly run tests within the example folder.

Thank you in advance for your help!

Bug with subset step

Having the following feature:

Feature: A feature name
  @first
  Scenario: First scenario
    Given something
    When Foo bar
    Then print foo bar

  @second
  Scenario: Second scenario
    Given something
    When Foo bar taz
    Then print foo bar taz

When run this feature the When and the Then steps of the second scenario are not executed, instead of that the When and the Then steps of the first scenario are executed twice.

If I change the step to When Foo-bar taz then the step is executed.

Need an extra maintainer?

Hey @jonsamwell I hope this isn't too forward. I know maintaining OS projects is tough, and it's hard when it's just you doing it. If you'd like an extra hand, I'd be happy to help as a maintainer of this repo and/or flutter_gherkin. I couldn't find your contact info quickly; if you'd like to have a chat please drop me a line at tshedor [at] greenbits.com

How to run a single scenario?

If this already exists, I apologise in advance.

Whenever adding new scenarios, it would be super useful if it was possible to specify only one scenario to be tested instead of having to run all of the scenarios in the feature.

As a feature gets bigger and bigger, it'll will increase the length of time it takes to test new scenarios to ensure they are working as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.