Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlutterI18nDelegate is breaking tests #39

Closed
ghost opened this issue Jul 8, 2019 · 2 comments
Closed

FlutterI18nDelegate is breaking tests #39

ghost opened this issue Jul 8, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 8, 2019

I'm trying to create a WidgetHelper class that will build the MaterialApp for every test. In this class I use the FlutterI18nDelegate:

class WidgetTestHelper {
  const WidgetTestHelper();

  MaterialApp generateApp(Widget body,) {
    return MaterialApp(
      theme: theme.light,
      localizationsDelegates: [
        FlutterI18nDelegate(
            useCountryCode: true, fallbackFile: 'en', path: 'lib/assets/i18n'),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      home: Scaffold(
        body: body,
      ),
    );
  }
}

If I try now to run these tests together:

void main() {
  testWidgets('Should find a FlatButton', (WidgetTester tester) async {
    WidgetTestHelper helper = WidgetTestHelper();

    await tester.pumpWidget(helper.generateApp(FlatButton()));
    await tester.pumpAndSettle();
    expect(find.byType(FlatButton), findsOneWidget);
  });
  testWidgets('Should find a RaisedButton', (WidgetTester tester) async {
    WidgetTestHelper helper = WidgetTestHelper();
    await tester.pumpWidget(helper.generateApp(RaisedButton()));
    await tester.pumpAndSettle();
    expect(find.byType(RaisedButton), findsOneWidget);
  });
}

they will fail while, if I test them one by one, they succeed. If now I remove the FlutterI18nDelegate and run again the tests together, they will succeed. Is it possible that this FlutterI18nDelegate creates some dependency between these tests?

@ghost ghost closed this as completed Jul 10, 2019
@ghost
Copy link
Author

ghost commented Jul 10, 2019

Closed because there was an error in my implementation.

@ilteoood
Copy link
Owner

Hi,
Can you explain your fix?
I'm sure that someone will appreciate it 😁

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant