olexale / bdd_widget_test

A BDD-style widget testing library
MIT License
101 stars 30 forks source link

When you add a datatable as anything but the last step within background, all steps after the datatable get deleted #65

Closed daniel-deboeverie-lemon closed 9 months ago

daniel-deboeverie-lemon commented 9 months ago

So with the change I made in https://github.com/olexale/bdd_widget_test/pull/60 I have found an issue I'm having difficulty fixing.

An example:

Background:
    Given the following songs
    | artist           | title                |
    | 'The Beatles'    | 'Let It Be'          |
    | 'Camel'          | 'Slow yourself down' |
    And I wait

  Scenario: Testing scenario
    Given the following users exist <name> <twitter>
    | name            | twitter       |
    | 'Oleksandr'     | '@olexale'    |
    | 'Flutter'       | '@FlutterDev' |

should give:

// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_import, directives_ordering

import 'package:bdd_widget_test/data_table.dart' as bdd;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import './step/the_following_songs.dart';
import './step/i_wait.dart';
import './step/the_following_users_exist.dart';

void main() {
  group(\'\'\'Testing feature\'\'\', () {
    Future<void> bddSetUp(WidgetTester tester) async {
      await theFollowingSongs(tester, const bdd.DataTable([[artist, title], ['The Beatles', 'Let It Be'], ['Camel', 'Slow yourself down']]));
      await iWait(tester);
    }
    testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
      await bddSetUp(tester);
      await theFollowingUsersExist(tester, 'Oleksandr', '@olexale');
      await theFollowingUsersExist(tester, 'Flutter', '@FlutterDev');
    });
  });
}

but currently gives:

// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_import, directives_ordering

import 'package:bdd_widget_test/data_table.dart' as bdd;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import './step/the_following_songs.dart';
import './step/the_following_users_exist.dart';

void main() {
  group(\'\'\'Testing feature\'\'\', () {
    Future<void> bddSetUp(WidgetTester tester) async {
      await theFollowingSongs(tester, const bdd.DataTable([[artist, title], ['The Beatles', 'Let It Be'], ['Camel', 'Slow yourself down']]));
    }
    testWidgets(\'\'\'Testing scenario\'\'\', (tester) async {
      await bddSetUp(tester);
      await theFollowingUsersExist(tester, 'Oleksandr', '@olexale');
      await theFollowingUsersExist(tester, 'Flutter', '@FlutterDev');
    });
  });
}

With this issue I would also like to ask how you can debug a project like this? If It try to run tests from file instead of the overarching flutter test command, I get the following error: Dart library 'dart:ui' is not available on this platform

olexale commented 9 months ago

Thanks for raising the issue! I fixed in https://github.com/olexale/bdd_widget_test/commit/7f3a38d6fa3f2ef92cc33f08aec82e1a1005cec4

When I need to debug the package, I write a failing test.