Skip to content

Commit

Permalink
Merge branch 'develop' into lifecycle_callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Oct 13, 2023
2 parents 44dc28b + 555609d commit b9628a3
Show file tree
Hide file tree
Showing 29 changed files with 120 additions and 153 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
![Patrol promotial graphics][promo_graphics]

Simple yet powerful Flutter-first UI testing framework overcoming limitations of
`flutter_test`, `integration_test`, and `flutter_driver`.
`flutter_test`, `integration_test`, and `flutter_driver`. Created and supported
by [LeanCode](https://leancode.co).

Learn more about Patrol:

Expand Down
19 changes: 10 additions & 9 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
[
"Finders",
[
["Overview", "/patrol/finders/overview"],
["Usage", "/patrol/finders/usage"],
["Advanced", "/patrol/finders/advanced"],
["Using Patrol finders in widget tests", "/patrol/finders/finders-setup"]
["Overview", "/finders/overview"],
["Usage", "/finders/usage"],
["Advanced", "/finders/advanced"],
["Using Patrol finders in widget tests", "/finders/finders-setup"]
]
],
[
"Native automation",
[
["Overview", "/patrol/native/overview"],
["Usage", "/patrol/native/usage"],
["Advanced", "/patrol/native/advanced"],
["Feature parity", "/patrol/native/feature-parity"]
["Overview", "/native/overview"],
["Usage", "/native/usage"],
["Advanced", "/native/advanced"],
["Feature parity", "/native/feature-parity"]
]
],
[
Expand Down Expand Up @@ -62,6 +62,7 @@
]
],
["Effective Patrol", "/effective-patrol"],
["Tips and tricks", "/tips-and-tricks"]
["Tips and tricks", "/tips-and-tricks"],
["LeanCode", "https://leancode.co"]
]
}
47 changes: 14 additions & 33 deletions docs/cli-commands/build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Test Lab. It works the same as `patrol test`, except that it does run tests.

### Examples

**To build for Android in debug mode**
**To build a single test for Android in debug mode**

```
patrol build android --target integration_test/example_test.dart
Expand All @@ -46,48 +46,29 @@ or alternatively (but redundantly):
patrol build android --target integration_test/example_test.dart --debug
```

**To build for iOS device in release mode**
**To build all tests for Android in debug mode**

```
patrol build ios --target integration_test/example_test.dart --release
patrol build android
```

**To build for iOS simulator in debug mode**
**To build a single test for iOS device in release mode**

```
patrol build ios --target integration_test/example_test.dart --debug
```

### Caveats

Only a single test target file can be built. For example, consider the following
`integration_test` directory containing 4 test targets:

```
integration_test/
├── common.dart
├── example_test.dart
├── notifications_test.dart
├── permissions_location_test.dart
├── webview_login_test.dart
patrol build ios --target integration_test/example_test.dart --release
```

<Info>Dart file must end with `_test.dart` to be considered to be a test.</Info>

To build the app for testing on Android, you have to run:
**To build a single test for iOS simulator in debug mode**

```
patrol build android --target <your file>
patrol build ios --target integration_test/example_test.dart --debug
```

4 times, each time with a different `--target`, to get 4 different app binaries.

These 4 different binaries are almost the same – the only difference is the
entrypoint. This is needlessly inefficient for apps with many tests, but it's a
design flaw in the way integration testing in Flutter works.

[We know about this issue][bundling_issue] and we're aiming to fix it soon with
an approach we call "test bundling". This will dramatically speed up testing
apps with many integration tests.
### Under the hood

[bundling_issue]: https://github.com/leancodepl/patrol/issues/1004
The `patrol build` command walks through hierarchy of the `integration_test`
directory and finds all files that end with `_test.dart`, and then creates an
additional "test bundle" file that references all the tests it found. Thanks to
this, all tests are built into a single app binary - only a single build is
required. If you're curious to learn more about this problem, see [Flutter issue
#115751](https://github.com/flutter/flutter/issues/115751)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ up. To run `integration_test/example_test.dart` on a local Android or iOS device

To learn how to write Patrol tests, see [finders] and [native automation] sections.

[native automation]: /patrol/native/usage
[native automation]: /native/usage
[finders]: /patrol/finders/usage
[Using Patrol finders in widget tests]: /patrol/finders/finders-setup
[Here's why]: /patrol/native/advanced#embrace-the-native-tests
[Here's why]: /native/advanced#embrace-the-native-tests
[Patrol CLI]: https://pub.dev/packages/patrol_cli
40 changes: 25 additions & 15 deletions docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ title: Main
description: The powerful Flutter-first UI testing framework. Ready for action!
---

# About
# Patrol by LeanCode

![Patrol promotial graphics][promo_graphics]

Patrol is a new testing framework for Flutter. It builds on top of Flutter's
existing test tooling to let you do things which were previously impossible.
Patrol is a powerful, open-source testing framework for Flutter apps created and
maintained by [LeanCode] – one of the leading Flutter development consultancies
in the world. Patrol builds on top of Flutter's existing test tooling to enable
you to do things which were previously impossible.

Patrol lets you [access native features of the platform][native] that the
It lets you [access native features of the platform][native] that the
Flutter app is running on. Finally, you can interact with permission dialogs,
notifications, WebViews, change device settings, toggle Wi-Fi, and much more –
and you can code this very easily in plain Dart.
Expand All @@ -24,28 +26,36 @@ Patrol is also a revamped, production-quality version of Flutter's built-in
`integration_test` plugin. It fixes its shortcomings and enables features such
as full isolation between tests and sharding.

Patrol is an open-source project which is being developed and maintained by us –
[LeanCode][leancode]! We use it to test our clients' production-grade apps, and
you can do the same!
Patrol is a fully open-source project and we're proud to share it with the
awesome Flutter community.

Learn more about Patrol:
At LeanCode, we use Patrol to test our clients' production-grade apps, and you
can do the same!

- [Read the article about the first public pre-release][article_0x]
- [Read the article about the stable 1.0 release][article_1x]
- [Read the article about the about how Patrol fixes integration_test][article_2x]
<Info>[Get Patrol from pub.dev now!][patrol_on_pubdev]</Info>

or [get Patrol from pub.dev!][patrol_on_pubdev]
### Learn more about Patrol

See the talk we gave at Fluttercon 2023:

<YouTube id="WJKcZ5ob718" />

or [read the article][article_2x] explaining how Patrol fixes deficiencies of
Flutter's official integration_test plugin.

We also provide professional services related to Flutter app testing – check
them out:

[![Automated UI testing services][services_graphics]][services]

[leancode]: https://leancode.co
[native]: /patrol/native/overview
[finders]: /patrol/finders/overview
[native]: /native/overview
[finders]: /finders/overview
[hot restart]: /cli-commands/develop
[article_0x]: https://leancode.co/blog/patrol-flutter-first-ui-testing-framework
[article_1x]: https://leancode.co/blog/patrol-1-0-powerful-flutter-ui-testing-framework
[article_2x]: https://leancode.co/blog/patrol-2-0-improved-flutter-ui-testing
[promo_graphics]: /assets/promo.png
[patrol_on_pubdev]: https://pub.dev/packages/patrol
[services_graphics]: /assets/services.png
[services]: https://leancode.co/products/automated-ui-testing-in-flutter?utm_source=patrol_page&utm_medium=banner&utm_campaign=service
[services]: https://leancode.co/products/automated-ui-testing-in-flutter?utm_source=patrol_page&utm_medium=banner&utm_campaign=service
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impossible to reach 100%.
### Platfom support

Patrol works on virtual and physical devices running Android 5.0 (API 21) and
newer, and iOS 13 and newer.
newer, and iOS 11 and newer.

[#244]: https://github.com/leancodepl/patrol/issues/244
[#282]: https://github.com/leancodepl/patrol/issues/282
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 2.4.0-dev.1
## 2.4.0-dev.3

- Add support for iOS 11 and 12 (#1733)

## 2.3.1

- Add support for iOS 11 and 12 (#1733)
- Fix build-time and run-time crashes when app doesn't use Kotlin 1.8.x (#1782)

## 2.3.0

- Add support for nested test hierarchies using `group()`s (#1634)
Expand Down
11 changes: 7 additions & 4 deletions packages/patrol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
[![codestyle][pub_badge_style]][pub_badge_link]

`patrol` package builds on top of `flutter_test` and `integration_test` to make
it easy to control the native UI from Dart test code.
it easy to control the native UI from Dart test code. Created and supported by
[LeanCode](https://leancode.co).

It also provides a new custom finder system to make Flutter widget tests more
concise and understandable, and writing them – faster and more fun.
It must be used together with [patrol_cli].

It can be used on its own or with [patrol_cli].
It also provides a new custom finder system to make Flutter widget tests more
concise and understandable, and writing them – faster and more fun. It you want
to only use custom finders, check out
[patrol_finders](https://pub.dev/packages/patrol_finders).

## Installation

Expand Down
9 changes: 5 additions & 4 deletions packages/patrol/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ buildscript {
classpath "com.android.tools.build:gradle:7.4.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.0"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: "kotlinx-serialization"

ktlint {
filter {
Expand Down Expand Up @@ -65,11 +63,14 @@ android {
api "androidx.test.espresso:espresso-core:3.5.0"
api "androidx.test.uiautomator:uiautomator:2.2.0"

implementation platform("org.http4k:http4k-bom:5.7.4.0")
// We need to downgrade http4k-bom to 4.48.0.0 because apps with kotlin version (ext.kotlin_version) lower than 1.8
// end up with compile-time errors. We can find more details in a similar problem:
// https://stackoverflow.com/questions/67699823/module-was-compiled-with-an-incompatible-version-of-kotlin-the-binary-version-o
implementation platform("org.http4k:http4k-bom:4.48.0.0")
implementation "org.http4k:http4k-core"
implementation "com.squareup.okhttp:okhttp:2.7.5" // See https://github.com/square/okhttp/issues/8031
implementation "org.http4k:http4k-server-ktorcio"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0"
implementation "com.google.code.gson:gson:2.10.1"

testImplementation "org.jetbrains.kotlin:kotlin-test"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package pl.leancode.patrol

import androidx.test.uiautomator.UiObjectNotFoundException
import kotlinx.serialization.json.Json
import org.http4k.core.Filter
import org.http4k.core.Response
import org.http4k.core.Status.Companion.INTERNAL_SERVER_ERROR
import org.http4k.core.Status.Companion.NOT_FOUND
import org.http4k.core.Status.Companion.NOT_IMPLEMENTED

private val json = Json { ignoreUnknownKeys = true }

val printer =
Filter { next ->
{ request ->
Expand Down
Loading

0 comments on commit b9628a3

Please sign in to comment.