channdara / flutter_localization

BSD 3-Clause "New" or "Revised" License
10 stars 17 forks source link

(Not An Issue) How can I write an integration test that demonstrates translation functionality? #12

Closed KeroJohn97 closed 5 months ago

KeroJohn97 commented 5 months ago

Hi Channdara, I understand that testing might not have been included in the initial design and development of this package. However, I'm reaching out to seek your guidance on implementing a mock class for FlutterLocalization. My goal is to display translated text within my app during the integration testing period. I've attempted to use the Mockito package to generate a mock class, but I encountered an issue with the init() method. It doesn't assign values to supportedLocales and localizationsDelegates, leading to the error: "'supportedLocales.isNotEmpty' is not true." I appreciate your understanding and any assistance you can provide. Thank you.

A Dart VM Service on sdk gphone64 x86 64 is available at: http://127.0.0.1:5539/AMOwvTPA464=/
The Flutter DevTools debugger and profiler on sdk gphone64 x86 64 is available at: http://127.0.0.1:9104?uri=http://127.0.0.1:5539/AMOwvTPA464=/
I/flutter (14693): (The following exception is now available via WidgetTester.takeException:)
I/flutter (14693): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (14693): The following assertion was thrown building MaterialApp(dirty, state: _MaterialAppState#d230e):
I/flutter (14693): 'package:flutter/src/widgets/app.dart': Failed assertion: line 462 pos 15:
I/flutter (14693): 'supportedLocales.isNotEmpty': is not true.
I/flutter (14693):
I/flutter (14693): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (14693): more information in this error message to help you determine and fix the underlying cause.
I/flutter (14693): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (14693):   https://github.com/flutter/flutter/issues/new?template=2_bug.yml
I/flutter (14693):
I/flutter (14693): The relevant error-causing widget was:
I/flutter (14693):   MaterialApp
I/flutter (14693):   MaterialApp:file:///C:/Users/xxx/xxx/test/screens/discover/discover_view_test.dart:76:28
channdara commented 5 months ago

Hello @KeroJohn97 I don't have experience with the Integration Test. Let me do some more research and try with my package. Will get back to you later. Sorry.

KeroJohn97 commented 5 months ago

I see. Thanks for the reply. I will switch to another localization for testing first. I hope the package becomes popular with more completed features. Peace.