Patrol logger issue in patrolSetUp()
Steps to reproduce
Hi guys,
There's a problem here, I see this kind of exception if the test fails in patrolSetUp(). Latest version, 3.14.1. Is it known issue?
Minimal reproducible example
import 'package:patrol/patrol.dart';
import 'package:test/test.dart';
void main() {
patrolSetUp(() async {
fail('Bye');
});
patrolTest(
'Test',
($) async {},
);
}
Actual results
I see an exception in the flutter logs that shouldn't be there, you can find details in the "Logs" section
Logs
Logs
% patrol test -t integration_test/test_test.dart --flavor dev -d emulator-5556
• Building apk with entrypoint test_bundle.dart...
✓ Completed building apk with entrypoint test_bundle.dart (12.3s)
• Executing tests of apk with entrypoint test_bundle.dart on emulator-5556...
Unhandled exception:
Bad state: No element
#0 List.last (dart:core-patch/growable_array.dart:353:5)
#1 PatrolLogReader.readEntries.<anonymous closure> (package:patrol_log/src/patrol_log_reader.dart:177:28)
#2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1778:10)
#3 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
#4 _DelayedData.perform (dart:async/stream_impl.dart:573:14)
#5 _PendingEvents.handleNext (dart:async/stream_impl.dart:678:11)
#6 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:649:7)
#7 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#8 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#9 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128:13)
#10 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:195:5)
Patrol version
patrol: ^3.14.1
Patrol Doctor output
Patrol Doctor output
<!-- Replace this line with your logs. Do not remove the backticks! -->
Flutter Doctor output
Flutter Doctor output
% patrol doctor
Patrol doctor:
Patrol CLI version: 3.5.1
Flutter command: flutter
Flutter 3.29.1 • channel stable
Android:
• Program adb found in /Users/olek/Library/Android/sdk/platform-tools//adb
• Env var $ANDROID_HOME set to /Users/olek/Library/Android/sdk
iOS / macOS:
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
Hi @alexks02, Thanks for reporting, we will check this 👀 .
Hi, do you have any updates? Thanks in advance, Olek
@alexks02 Why you want to use fail() in setup? You are right that this is an issue, but I would say with the low priority. Our backlog is long, and I couldn't say when it can be fixed, maybe we can find some other solution for your case :D,
Cheers Kendru
@Kendru98 Hello! This is the simplest example of a test failing in the patrolSetUp section to reproduce the above problem. It's not critical for me, I just stopped using patrolSetUp, but I decided to create an issue - just in case someone else encounters it and knows that it's a known issue :-) Best regards, Olek
Hi, It is not like just fail() causes this error? And if you for example use .waitUntilVisible() there, error trace will be correct 🤔
Cheers, Szymon
Hi @Kendru98
I couldn't find a way how to pass PatrolIntegrationTester $ into patrolSetUp(), so in my real case it was something like
expect(something, somethingAnother);
Hi, You can get NativeAutomator $.native2 and then use native patrol features there
example: final automator = NativeAutomator(config: nativeConfig);
But I don't understand how I can get PatrolIntegrationTester $ from this NativeAutomator object
If you want to use PatrolIntegrationTester $ just do it in test body. What is your usecase? setUp is mainly for setting stuff via API or do some native actions like take a photo or ON Bluetooth
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.