Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/cli-commands/test.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ patrol test --build-name=1.2.3 --build-number=123
patrol test --target patrol_test/login_test.dart --build-name=1.2.3 --build-number=123
```

### Skipping the build step

If you have already built your app binaries using [`patrol build`][patrol_build],
you can skip the build step with `--no-build`:

```
patrol build android
patrol test --no-build
```

This is useful in CI pipelines or iterative workflows where you want to build
once and run tests multiple times without rebuilding. The previously built
binaries are picked up from their default output paths.

### Isolation of test runs

To achieve full isolation between test runs:
Expand Down
1 change: 1 addition & 0 deletions packages/patrol_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 4.3.1

- Add `--no-build` flag to `patrol test` to skip the build step and use previously built binaries.
- Update dependencies.

## 4.3.0
Expand Down
18 changes: 16 additions & 2 deletions packages/patrol_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,22 @@ Read the documentation:
- [setup](https://patrol.leancode.pl/getting-started)
- [test command](https://patrol.leancode.co/cli-commands/test)

## 🛠️ Maintained by LeanCode
### Skipping the build step

If you want to separate the build and test steps (e.g. to build once and run
tests multiple times), you can use `patrol build` to pre-build and then
`patrol test --no-build` to run with the existing binaries:

```console
$ patrol build android
$ patrol test --no-build
```

The `--no-build` flag tells `patrol test` to skip the build step entirely and
use the binaries previously produced by `patrol build android` (or
`patrol build ios`). The binaries are expected at their default output paths.

## Maintained by LeanCode

<div align="center">
<a href="https://leancode.co/?utm_source=github.com&utm_medium=referral&utm_campaign=patrol-readme">
Expand Down Expand Up @@ -103,7 +118,6 @@ We are **top-tier experts** focused on Flutter Enterprise solutions.
[Check our other packages](https://pub.dev/packages?q=publisher%3Aleancode.co&sort=downloads)

</div>

[pub_link]: https://pub.dartlang.org/packages/patrol_cli
[pub_badge_style]: https://img.shields.io/badge/style-leancode__lint-black
[pub_badge_link]: https://pub.dartlang.org/packages/leancode_lint
Expand Down
12 changes: 9 additions & 3 deletions packages/patrol_cli/lib/src/commands/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class TestCommand extends PatrolCommand {
usesBuildNumberOption();

usesUninstallOption();
usesNoBuildOption();

usesAndroidOptions();
usesIOSOptions();
Expand Down Expand Up @@ -319,11 +320,16 @@ See https://github.com/leancodepl/patrol/issues/1316 to learn more.
browserArgs: stringArg('web-browser-args'),
);

// No need to build web app for testing. It's done in the execute method.
if (device.targetPlatform != TargetPlatform.web) {
if (!boolArg('build')) {
_logger.info('Skipping build step (--no-build)');
if (device.targetPlatform == TargetPlatform.android) {
await _androidTestBackend
.loadJavaPathFromFlutterDoctor(flutterOpts.command);
}
} else if (device.targetPlatform != TargetPlatform.web) {
// No need to build web app for testing. It's done in the execute method.
await _build(androidOpts, iosOpts, macosOpts, webOpts, device);
}

await _preExecute(androidOpts, iosOpts, macosOpts, device, uninstall);

if (coverageEnabled) {
Expand Down
10 changes: 10 additions & 0 deletions packages/patrol_cli/lib/src/runner/patrol_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ abstract class PatrolCommand extends Command<int> {
);
}

void usesNoBuildOption() {
argParser.addFlag(
'build',
defaultsTo: true,
help:
'Build the app before running tests. '
'Use --no-build to skip the build step and use previously built binaries.',
);
}

void usesBuildNameOption() {
argParser.addOption(
'build-name',
Expand Down
Loading