Skip to content
New issue

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

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

Already on GitHub? # to your account

Crdzbird/unit test flutter #259

Merged
merged 12 commits into from
Jul 30, 2021
Merged

Conversation

Crdzbird
Copy link

The test at the time has a tiny percentage of code coverage, hope that this will increase at their respective moment, also added documentation about how to run and generate the visual graph.

  • If you refactored existing code, have you tested the refactored functionality against the old version to make sure you didn't break anything?
  • Do the tests pass? Consistently?
  • Did this change improve test coverage?
  • Is the code in question being linted? If not, consider adding a linter step to CI. If yes, make sure the linter is happy.
  • Have you logged tickets for related technical debt with the label “techdebt”?

@Crdzbird Crdzbird requested a review from oxtoacart July 29, 2021 20:02
@oxtoacart
Copy link

Awesome to have some tests!

@@ -84,6 +84,43 @@ Once the required tools are installed and the lfs are downloaded, open the proje
- Edit the run config and add on the flavor option prod


## Unit Tests

To run the unit test you need to input the following setup.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do this from the command line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. an example would be:

flutter run test/catcher_test.dart --coverage or
flutter run test/catcher_test.dart

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wish to run everything just replace the catcher_test with an * and it should run everything

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you add that to the readme please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

README.md Outdated

1. On your `terminal` check if you have installed: `lcov` if not then install.
2. Go to on your terminal `android-lantern/coverage` and type: `genhtml coverage/lcov.info -o coverage/html` that will generate a nice html file with the code coverage of all your files.
#### NOTE: Please avoid to upload the generated files from coverage, this is because the numerous files that are created.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the necessary directories/files to .gitignore?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, im gonna omit the coverage and genhtml

@@ -0,0 +1,4857 @@
SF:lib/config/catcher_setup.dart

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be checked in?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually... that is also needed to be omitted, im gonna add it to the .gitignore as suggested

@oxtoacart
Copy link

I can't run the test from the command line

➜  android-lantern git:(crdzbird/unit_test_flutter) flutter run test/app_test.dart
Multiple devices found:
MHA L29 (mobile)                   • 5REFL18614000020 • android-arm64 • Android 8.0.0 (API 26)
LG H918 (mobile)                   • LGH918e050e1b    • android-arm64 • Android 8.0.0 (API 26)
Android SDK built for x86 (mobile) • emulator-5554    • android-x86   • Android 5.1.1 (API 22) (emulator)
[1]: MHA L29 (5REFL18614000020)
[2]: LG H918 (LGH918e050e1b)
[3]: Android SDK built for x86 (emulator-5554)
Please choose one (To quit, press "q/Q"): 2
Running "flutter pub get" in android-lantern...                  1,335ms
Launching test/app_test.dart on LG H918 in debug mode...
Note: /Users/ox.to.a.cart/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.2/android/src/main/java/com/jrai/flutter_keyboard_visibility/FlutterKeyboardVisibilityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        72.6s
Exception: Unsupported Android Plugin version: 4.2.1.

@Crdzbird
Copy link
Author

I can't run the test from the command line

➜  android-lantern git:(crdzbird/unit_test_flutter) flutter run test/app_test.dart
Multiple devices found:
MHA L29 (mobile)                   • 5REFL18614000020 • android-arm64 • Android 8.0.0 (API 26)
LG H918 (mobile)                   • LGH918e050e1b    • android-arm64 • Android 8.0.0 (API 26)
Android SDK built for x86 (mobile) • emulator-5554    • android-x86   • Android 5.1.1 (API 22) (emulator)
[1]: MHA L29 (5REFL18614000020)
[2]: LG H918 (LGH918e050e1b)
[3]: Android SDK built for x86 (emulator-5554)
Please choose one (To quit, press "q/Q"): 2
Running "flutter pub get" in android-lantern...                  1,335ms
Launching test/app_test.dart on LG H918 in debug mode...
Note: /Users/ox.to.a.cart/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-5.0.2/android/src/main/java/com/jrai/flutter_keyboard_visibility/FlutterKeyboardVisibilityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        72.6s
Exception: Unsupported Android Plugin version: 4.2.1.

flutter test test/file.dart

@Crdzbird
Copy link
Author

I notice that I forget to update one test

@@ -32,6 +32,10 @@ app.iml
# is commented out by default.
.vscode/

coverage
coverage/html/
coverage/lcov.info
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added coverage folder to .gitignore

### Run Independent Tests

On your terminal go to the root of the project and type:
`flutter test test/my_folder_test.dart`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of how to run flutter unit test without coverage

`flutter test test/my_folder_test.dart`

in case that you need the code coverage just add the following argument.
`flutter test --coverage test/my_folder_test.dart`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of how to run flutter unit test with coverage

If you wanna visualize the current percentage of code coverage you need to do the following steps.

1. On your `terminal` check if you have installed: `lcov` if not then install.
2. Go to on your terminal `android-lantern/coverage` and type: `genhtml coverage/lcov.info -o coverage/html` that will generate a nice html file with the code coverage of all your files.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation about how to generate a informative graph about the percentage of code coverage on the project.

@@ -109,6 +109,7 @@ dev_dependencies:
sdk: flutter

test: ^1.15.7
mockito: ^5.0.12
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mockit is used in order to be capable to emulated some specific code ex: auto_route

@oxtoacart
Copy link

flutter test test/file.dart

Thanks!

If I run all tests, the catcher_test fails. I don't think that's new to this branch, but since you're in here, would you mind taking a look please?

➜  android-lantern git:(crdzbird/unit_test_flutter) flutter test
00:02 +0: /Volumes/external/git/android-lantern/test/app_test.dart: Widget startup Check for everything being loaded on the root
Load the root widget without catcher
00:02 +0: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart
Load the root widget without catcher
00:03 +0: /Volumes/external/git/android-lantern/test/app_test.dart: Widget startup Check for everything being loaded on the root
Declare a variable of type [GlobalLoaderOverlay]
If the root was loaded successfully it should find [GlobalLoaderOverlay]
Declare a variable of type [Sizer]
If the root was loaded successfully it should find [Sizer]
Declare a variable of type [MaterialApp.router]
If the root was loaded successfully it should find [MaterialApp.router]
00:03 +1: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart
Check for the BaseScreen to be loaded correctly
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _WidgetTypeFinder:<zero widgets with type "BaseScreen" (ignoring offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure>.<anonymous closure> (file:///Volumes/external/git/android-lantern/test/base_screen_test.dart:17:11)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
...

This was caught by the test expectation on the following line:
  file:///Volumes/external/git/android-lantern/test/base_screen_test.dart line 17
The test description was:
  Test coverage for base_screen.dart
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +1 -1: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart [E]
  Test failed. See exception logs above.
  The test description was: Test coverage for base_screen.dart

00:03 +1 -1: /Volumes/external/git/android-lantern/test/catcher_test.dart: Test Catcher
[2021-07-30 08:08:59.911624 | Catcher | WARNING] Screenshots path is empty. Screenshots won't work.
[2021-07-30 08:08:59.923992 | Catcher | FINE] Catcher configured successfully.
[2021-07-30 08:08:59.926453 | Catcher | INFO] Setup localization lazily!
[2021-07-30 08:09:00.044656 | Catcher | INFO] ============================== CATCHER LOG ==============================
[2021-07-30 08:09:00.045121 | Catcher | INFO] Crash occurred on 2021-07-30 08:09:00.042109
[2021-07-30 08:09:00.045429 | Catcher | INFO]
[2021-07-30 08:09:00.045868 | Catcher | INFO] ------- DEVICE INFO -------
[2021-07-30 08:09:00.046465 | Catcher | INFO]
[2021-07-30 08:09:00.046895 | Catcher | INFO] ------- APP INFO -------
[2021-07-30 08:09:00.047575 | Catcher | INFO] environment: debug
[2021-07-30 08:09:00.047847 | Catcher | INFO]
[2021-07-30 08:09:00.048060 | Catcher | INFO] ---------- ERROR ----------
[2021-07-30 08:09:00.048310 | Catcher | INFO] 'package:flutter_test/src/binding.dart': Failed assertion: line 1060 pos 12: 'inTest': is not true.
[2021-07-30 08:09:00.048555 | Catcher | INFO]
[2021-07-30 08:09:00.048968 | Catcher | INFO] ------- STACK TRACE -------
[2021-07-30 08:09:00.049461 | Catcher | INFO] #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
[2021-07-30 08:09:00.049703 | Catcher | INFO] #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
[2021-07-30 08:09:00.050030 | Catcher | INFO] #2      AutomatedTestWidgetsFlutterBinding.scheduleAttachRootWidget (package:flutter_test/src/binding.dart:1060:12)
[2021-07-30 08:09:00.050358 | Catcher | INFO] #3      runApp (package:flutter/src/widgets/binding.dart:1028:7)
[2021-07-30 08:09:00.050816 | Catcher | INFO] #4      Catcher._setupErrorHooks.<anonymous closure> (package:catcher/core/catcher.dart:200:9)
[2021-07-30 08:09:00.051084 | Catcher | INFO] #5      Catcher._runZonedGuarded.<anonymous closure> (package:catcher/core/catcher.dart:216:15)
[2021-07-30 08:09:00.051306 | Catcher | INFO] #6      Catcher._runZonedGuarded.<anonymous closure> (package:catcher/core/catcher.dart:212:35)
[2021-07-30 08:09:00.051524 | Catcher | INFO] #7      _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.051764 | Catcher | INFO] #8      _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.052010 | Catcher | INFO] #9      _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.052286 | Catcher | INFO] #10     runZonedGuarded (dart:async/zone.dart:1777:12)
[2021-07-30 08:09:00.052550 | Catcher | INFO] #11     Catcher._runZonedGuarded (package:catcher/core/catcher.dart:212:5)
[2021-07-30 08:09:00.052793 | Catcher | INFO] #12     Catcher._setupErrorHooks (package:catcher/core/catcher.dart:199:7)
[2021-07-30 08:09:00.053 | Catcher | INFO] #13     Catcher._configure (package:catcher/core/catcher.dart:81:5)
[2021-07-30 08:09:00.053208 | Catcher | INFO] #14     new Catcher (package:catcher/core/catcher.dart:73:5)
[2021-07-30 08:09:00.053411 | Catcher | INFO] #15     setupCatcherAndRun (package:lantern/config/catcher_setup.dart:36:10)
[2021-07-30 08:09:00.053688 | Catcher | INFO] #16     main.<anonymous closure> (file:///Volumes/external/git/android-lantern/test/catcher_test.dart:9:15)
[2021-07-30 08:09:00.053956 | Catcher | INFO] #17     Declarer._runSetUps.<anonymous closure> (package:test_api/src/backend/declarer.dart:330:61)
[2021-07-30 08:09:00.054186 | Catcher | INFO] #18     Future.forEach.<anonymous closure> (dart:async/future.dart:495:26)
[2021-07-30 08:09:00.054400 | Catcher | INFO] #19     Future.doWhile.<anonymous closure> (dart:async/future.dart:535:26)
[2021-07-30 08:09:00.054752 | Catcher | INFO] #20     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
[2021-07-30 08:09:00.055200 | Catcher | INFO] #21     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
[2021-07-30 08:09:00.055419 | Catcher | INFO] #22     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
[2021-07-30 08:09:00.055625 | Catcher | INFO] #23     _rootRunUnary (dart:async/zone.dart:1362:47)
[2021-07-30 08:09:00.055826 | Catcher | INFO] #24     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
[2021-07-30 08:09:00.056063 | Catcher | INFO] #25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
[2021-07-30 08:09:00.056292 | Catcher | INFO] #26     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1207:26)
[2021-07-30 08:09:00.056505 | Catcher | INFO] #27     Future.doWhile (dart:async/future.dart:551:18)
[2021-07-30 08:09:00.056903 | Catcher | INFO] #28     Future.forEach (dart:async/future.dart:493:12)
[2021-07-30 08:09:00.057117 | Catcher | INFO] #29     Declarer._runSetUps (package:test_api/src/backend/declarer.dart:330:18)
[2021-07-30 08:09:00.057307 | Catcher | INFO] #30     Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:199:15)
[2021-07-30 08:09:00.057493 | Catcher | INFO] #31     Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:198:22)
[2021-07-30 08:09:00.057674 | Catcher | INFO] #32     _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.057851 | Catcher | INFO] #33     _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.058026 | Catcher | INFO] #34     _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.058201 | Catcher | INFO] #35     runZoned (dart:async/zone.dart:1711:10)
[2021-07-30 08:09:00.058395 | Catcher | INFO] #36     Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:198:13)
[2021-07-30 08:09:00.058578 | Catcher | INFO] #37     Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:181:48)
[2021-07-30 08:09:00.058764 | Catcher | INFO] #38     Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:231:15)
[2021-07-30 08:09:00.058960 | Catcher | INFO] #39     Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:228:14)
[2021-07-30 08:09:00.059143 | Catcher | INFO] #40     _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.059329 | Catcher | INFO] #41     _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.059510 | Catcher | INFO] #42     _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.059710 | Catcher | INFO] #43     runZoned (dart:async/zone.dart:1711:10)
[2021-07-30 08:09:00.059974 | Catcher | INFO] #44     Invoker.waitForOutstandingCallbacks (package:test_api/src/backend/invoker.dart:228:5)
[2021-07-30 08:09:00.060237 | Catcher | INFO] #45     Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:383:17)
[2021-07-30 08:09:00.060570 | Catcher | INFO] <asynchronous suspension>
[2021-07-30 08:09:00.060882 | Catcher | INFO]
[2021-07-30 08:09:00.061707 | Catcher | INFO] ------- CUSTOM INFO -------
[2021-07-30 08:09:00.062912 | Catcher | INFO] ======================================================================
Catcher is just a wrapper that notify any 3rd party error handler
Catcher should throw a custom exception and the logger should be displayed on the console
[2021-07-30 08:09:00.089251 | Catcher | INFO] Report result: true
00:03 +2 -1: Some tests failed.

@Crdzbird
Copy link
Author

flutter test test/file.dart

Thanks!

If I run all tests, the catcher_test fails. I don't think that's new to this branch, but since you're in here, would you mind taking a look please?

➜  android-lantern git:(crdzbird/unit_test_flutter) flutter test
00:02 +0: /Volumes/external/git/android-lantern/test/app_test.dart: Widget startup Check for everything being loaded on the root
Load the root widget without catcher
00:02 +0: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart
Load the root widget without catcher
00:03 +0: /Volumes/external/git/android-lantern/test/app_test.dart: Widget startup Check for everything being loaded on the root
Declare a variable of type [GlobalLoaderOverlay]
If the root was loaded successfully it should find [GlobalLoaderOverlay]
Declare a variable of type [Sizer]
If the root was loaded successfully it should find [Sizer]
Declare a variable of type [MaterialApp.router]
If the root was loaded successfully it should find [MaterialApp.router]
00:03 +1: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart
Check for the BaseScreen to be loaded correctly
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _WidgetTypeFinder:<zero widgets with type "BaseScreen" (ignoring offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure>.<anonymous closure> (file:///Volumes/external/git/android-lantern/test/base_screen_test.dart:17:11)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
...

This was caught by the test expectation on the following line:
  file:///Volumes/external/git/android-lantern/test/base_screen_test.dart line 17
The test description was:
  Test coverage for base_screen.dart
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +1 -1: /Volumes/external/git/android-lantern/test/base_screen_test.dart: Widget startup Test coverage for base_screen.dart [E]
  Test failed. See exception logs above.
  The test description was: Test coverage for base_screen.dart

00:03 +1 -1: /Volumes/external/git/android-lantern/test/catcher_test.dart: Test Catcher
[2021-07-30 08:08:59.911624 | Catcher | WARNING] Screenshots path is empty. Screenshots won't work.
[2021-07-30 08:08:59.923992 | Catcher | FINE] Catcher configured successfully.
[2021-07-30 08:08:59.926453 | Catcher | INFO] Setup localization lazily!
[2021-07-30 08:09:00.044656 | Catcher | INFO] ============================== CATCHER LOG ==============================
[2021-07-30 08:09:00.045121 | Catcher | INFO] Crash occurred on 2021-07-30 08:09:00.042109
[2021-07-30 08:09:00.045429 | Catcher | INFO]
[2021-07-30 08:09:00.045868 | Catcher | INFO] ------- DEVICE INFO -------
[2021-07-30 08:09:00.046465 | Catcher | INFO]
[2021-07-30 08:09:00.046895 | Catcher | INFO] ------- APP INFO -------
[2021-07-30 08:09:00.047575 | Catcher | INFO] environment: debug
[2021-07-30 08:09:00.047847 | Catcher | INFO]
[2021-07-30 08:09:00.048060 | Catcher | INFO] ---------- ERROR ----------
[2021-07-30 08:09:00.048310 | Catcher | INFO] 'package:flutter_test/src/binding.dart': Failed assertion: line 1060 pos 12: 'inTest': is not true.
[2021-07-30 08:09:00.048555 | Catcher | INFO]
[2021-07-30 08:09:00.048968 | Catcher | INFO] ------- STACK TRACE -------
[2021-07-30 08:09:00.049461 | Catcher | INFO] #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
[2021-07-30 08:09:00.049703 | Catcher | INFO] #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
[2021-07-30 08:09:00.050030 | Catcher | INFO] #2      AutomatedTestWidgetsFlutterBinding.scheduleAttachRootWidget (package:flutter_test/src/binding.dart:1060:12)
[2021-07-30 08:09:00.050358 | Catcher | INFO] #3      runApp (package:flutter/src/widgets/binding.dart:1028:7)
[2021-07-30 08:09:00.050816 | Catcher | INFO] #4      Catcher._setupErrorHooks.<anonymous closure> (package:catcher/core/catcher.dart:200:9)
[2021-07-30 08:09:00.051084 | Catcher | INFO] #5      Catcher._runZonedGuarded.<anonymous closure> (package:catcher/core/catcher.dart:216:15)
[2021-07-30 08:09:00.051306 | Catcher | INFO] #6      Catcher._runZonedGuarded.<anonymous closure> (package:catcher/core/catcher.dart:212:35)
[2021-07-30 08:09:00.051524 | Catcher | INFO] #7      _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.051764 | Catcher | INFO] #8      _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.052010 | Catcher | INFO] #9      _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.052286 | Catcher | INFO] #10     runZonedGuarded (dart:async/zone.dart:1777:12)
[2021-07-30 08:09:00.052550 | Catcher | INFO] #11     Catcher._runZonedGuarded (package:catcher/core/catcher.dart:212:5)
[2021-07-30 08:09:00.052793 | Catcher | INFO] #12     Catcher._setupErrorHooks (package:catcher/core/catcher.dart:199:7)
[2021-07-30 08:09:00.053 | Catcher | INFO] #13     Catcher._configure (package:catcher/core/catcher.dart:81:5)
[2021-07-30 08:09:00.053208 | Catcher | INFO] #14     new Catcher (package:catcher/core/catcher.dart:73:5)
[2021-07-30 08:09:00.053411 | Catcher | INFO] #15     setupCatcherAndRun (package:lantern/config/catcher_setup.dart:36:10)
[2021-07-30 08:09:00.053688 | Catcher | INFO] #16     main.<anonymous closure> (file:///Volumes/external/git/android-lantern/test/catcher_test.dart:9:15)
[2021-07-30 08:09:00.053956 | Catcher | INFO] #17     Declarer._runSetUps.<anonymous closure> (package:test_api/src/backend/declarer.dart:330:61)
[2021-07-30 08:09:00.054186 | Catcher | INFO] #18     Future.forEach.<anonymous closure> (dart:async/future.dart:495:26)
[2021-07-30 08:09:00.054400 | Catcher | INFO] #19     Future.doWhile.<anonymous closure> (dart:async/future.dart:535:26)
[2021-07-30 08:09:00.054752 | Catcher | INFO] #20     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
[2021-07-30 08:09:00.055200 | Catcher | INFO] #21     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
[2021-07-30 08:09:00.055419 | Catcher | INFO] #22     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
[2021-07-30 08:09:00.055625 | Catcher | INFO] #23     _rootRunUnary (dart:async/zone.dart:1362:47)
[2021-07-30 08:09:00.055826 | Catcher | INFO] #24     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
[2021-07-30 08:09:00.056063 | Catcher | INFO] #25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
[2021-07-30 08:09:00.056292 | Catcher | INFO] #26     _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1207:26)
[2021-07-30 08:09:00.056505 | Catcher | INFO] #27     Future.doWhile (dart:async/future.dart:551:18)
[2021-07-30 08:09:00.056903 | Catcher | INFO] #28     Future.forEach (dart:async/future.dart:493:12)
[2021-07-30 08:09:00.057117 | Catcher | INFO] #29     Declarer._runSetUps (package:test_api/src/backend/declarer.dart:330:18)
[2021-07-30 08:09:00.057307 | Catcher | INFO] #30     Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:199:15)
[2021-07-30 08:09:00.057493 | Catcher | INFO] #31     Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:198:22)
[2021-07-30 08:09:00.057674 | Catcher | INFO] #32     _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.057851 | Catcher | INFO] #33     _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.058026 | Catcher | INFO] #34     _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.058201 | Catcher | INFO] #35     runZoned (dart:async/zone.dart:1711:10)
[2021-07-30 08:09:00.058395 | Catcher | INFO] #36     Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:198:13)
[2021-07-30 08:09:00.058578 | Catcher | INFO] #37     Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:181:48)
[2021-07-30 08:09:00.058764 | Catcher | INFO] #38     Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:231:15)
[2021-07-30 08:09:00.058960 | Catcher | INFO] #39     Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:228:14)
[2021-07-30 08:09:00.059143 | Catcher | INFO] #40     _rootRun (dart:async/zone.dart:1354:13)
[2021-07-30 08:09:00.059329 | Catcher | INFO] #41     _CustomZone.run (dart:async/zone.dart:1258:19)
[2021-07-30 08:09:00.059510 | Catcher | INFO] #42     _runZoned (dart:async/zone.dart:1789:10)
[2021-07-30 08:09:00.059710 | Catcher | INFO] #43     runZoned (dart:async/zone.dart:1711:10)
[2021-07-30 08:09:00.059974 | Catcher | INFO] #44     Invoker.waitForOutstandingCallbacks (package:test_api/src/backend/invoker.dart:228:5)
[2021-07-30 08:09:00.060237 | Catcher | INFO] #45     Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:383:17)
[2021-07-30 08:09:00.060570 | Catcher | INFO] <asynchronous suspension>
[2021-07-30 08:09:00.060882 | Catcher | INFO]
[2021-07-30 08:09:00.061707 | Catcher | INFO] ------- CUSTOM INFO -------
[2021-07-30 08:09:00.062912 | Catcher | INFO] ======================================================================
Catcher is just a wrapper that notify any 3rd party error handler
Catcher should throw a custom exception and the logger should be displayed on the console
[2021-07-30 08:09:00.089251 | Catcher | INFO] Report result: true
00:03 +2 -1: Some tests failed.

Interesting it seems that the error is not actually on the catcher but rather on base_screen, will take a look on that

}),
));
await tester.pumpAndSettle();
expect(find.byType(HomePage), findsOneWidget);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error was due to the widget still wasn't settle and also the multi provider wasn't inside the scope

@Crdzbird
Copy link
Author

@oxtoacart All tests should be working, also for any navigation test is preferable to use the Mockito to avoid any mislead, for further information: https://flutteragency.com/test-navigation-in-flutter/

@oxtoacart
Copy link

Awesome @Crdzbird ! I love the documentation.

@oxtoacart oxtoacart merged commit 09ad952 into ox/messaging Jul 30, 2021
@oxtoacart oxtoacart deleted the crdzbird/unit_test_flutter branch July 30, 2021 21:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants