-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add shell to PatrolIntegrationTester
, or ability to execute code on testing machine
#2386
Comments
this was implemented in #630 but then removed |
Hello @bartekpacia, since it was removed, is there any workaround to achieve the desired action? |
I am also stuck in a similar situation. Is there any workaround? |
@kikuchy One way around this, that I have thought about, but not actually implemented, is to create a separate dedicated app just to test the Instant App invocation. I assume this is your case, and you are not in need to run some random code on the host machine before a test. |
@Sevastyan Thank you for response! In my case, it's ok to run test only on Android and throwing Intent, it's looks like to be enough to use |
I needed to run a CLI command on the host machine (Mac OS) during an E2E test using Patrol. The tests run on an Android device, but during the test, I had to set up the server environment and verify if the client responded correctly. Since My workaroundI created a simple Python web service that wraps the CLI tool, allowing me to execute commands remotely via HTTP from my tests. Example Scenario
Calling the Tool from Code// Create long-lived token command
final createToken = [
'raw',
'ws',
'auth/long_lived_access_token',
'--json={"lifespan":3650,"client_name":"$_clientName"}'
].join(' ');
final result = await _cli.execute(createToken);
// Execute implementation
Future<Either<CommandError, CommandResult>> execute(String command) async {
try {
final response = await http.post(
Uri.parse(_cliServerUrl),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'command': command,
'token': _token,
}),
);
final data = jsonDecode(response.body);
return Right(
CommandResult(
stdout: data['stdout'],
stderr: data['stderr'],
exitCode: data['exit_code'],
),
);
} catch (e) {
return Left(CommandError('Failed to execute command', e));
}
} This setup allows executing CLI commands remotely, similar to a lightweight remote terminal over HTTP. It currently wraps a single tool, but it could be extended to support more general remote execution. I used this approach for my project https://github.com/seftoner/hommie |
Use case
I am writing patrol test to test my Flutter app on Android emulator on my machine. I want to be able to run terminal commands on my host machine during the patrol test (inside the
PatrolTesterCallback
).This feature request is indeed related to the problem I am having, however the feature will serve a much wider variety of cases than described shortly.
So, the problem is that I cannot trigger Android's flow for handling URLs of Instant Apps. When testing manually, I usually fire this terminal command:
adb shell 'am start -a android.intent.action.VIEW -d "https://..." com.my.applicationId'
this brings up this system UI:
And then, when testing manually, I click "OPEN APP", which opens Android Instant App, from which I download my full app and get to testing further.
The
adb
command above is not the only one I wish to be able to run from within the patrol test. I also want to generate the URL during the test, and for this I have a nifty CLI command on my machine (it contacts my server to get me the URL).To sum up, I want to start my patrol test by running a few terminal commands (executing them on my host machine), and then start using patrol's finders to assert what is shown on the emulator's screen.
What I have tried:
There is already a native
openUrl
method provided by patrol. However, it never opens the Android's UI as in the picture above - it simply opens the browser (not even my app, which actually handles the URL nicely).openUrl
will only open my app, if the URL schema is a custom schema that my app supports. I mean, my app support both "https://" and "mycustomapp" shemas. But with patrol I am not able to test "https" schema, as it always opens the browser. This, obviously, makes it impossible to test the real user flow - user clicking on the URL, user making a decision to continue viewing the URL in the Instant App, user interacting with Instant App, user downloading the full app, and user interacting with the full app.Proposal
The text was updated successfully, but these errors were encountered: