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

Strings are null at UI tests #17

Open
kndl22 opened this issue Sep 1, 2020 · 3 comments
Open

Strings are null at UI tests #17

kndl22 opened this issue Sep 1, 2020 · 3 comments

Comments

@kndl22
Copy link

kndl22 commented Sep 1, 2020

Hi,
I'm building a UI test for my screen - and the test is failing when calling S.of(context).someText

The test:

void main(){
  testWidgets('Intro screen test', (WidgetTester tester) async {
    GetIt.instance.reset();
    locator.registerSingleton(KeyboardManager());

    await tester.pumpWidget(buildTestableWidget(IntroScreen()));
    await tester.pumpAndSettle();

    final buttonFinder = find.byType(IntroCtaButton);

    expect(buttonFinder, findsNWidgets(2));
  });
}

Widget buildTestableWidget(Widget widget) {
  return MediaQuery(
    data: const MediaQueryData(),
    child: MaterialApp(
      localizationsDelegates: const [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      supportedLocales: S.delegate.supportedLocales,
      home: widget,
    ),
  );
}

The error:
The getter 'someText' was called on null.

Seen some related issue like this and this medium article but couldn't get it working.

@KingWu
Copy link
Owner

KingWu commented Sep 2, 2020

I tested your setup on my project. Does not face this issue.
Can you show flutter doctor?

@kndl22
Copy link
Author

kndl22 commented Sep 2, 2020

Flutter doctor:

[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G73, locale en-IL)
    • Flutter version 1.20.2 at /Users/yuv/Developer/flutter
    • Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/yuv/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.7, Build version 11E801a
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (2 available)
    • Android SDK built for x86 (mobile) • emulator-5554
      • android-x86 • Android 10 (API 29) (emulator)
    • iPhone 11 (mobile)                 • 1811ECB0-2C0F-445B-8226-B2A9A5A0AF50
      • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)

• No issues found!

@KingWu
Copy link
Owner

KingWu commented Sep 3, 2020

just upgrade to 1.20.3. And run test case and passed.
try to upgrade 1.20.3 and try again?

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

2 participants