feat: patrol on-device integration smoke test
This commit is contained in:
parent
d6f4c434fa
commit
6f6fa20b58
10 changed files with 466 additions and 6 deletions
|
|
@ -25,6 +25,25 @@ android {
|
|||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
// The Android Test Orchestrator (with clearPackageData) wipes the
|
||||
// integration flavor's app data between test runs, and the flavor
|
||||
// installs it beside — never over — the real app, so every patrol run
|
||||
// starts at onboarding with a fresh identity.
|
||||
testInstrumentationRunner = "pl.leancode.patrol.PatrolJUnitRunner"
|
||||
testInstrumentationRunnerArguments["clearPackageData"] = "true"
|
||||
}
|
||||
|
||||
testOptions {
|
||||
execution = "ANDROIDX_TEST_ORCHESTRATOR"
|
||||
}
|
||||
|
||||
flavorDimensions += "test"
|
||||
productFlavors {
|
||||
create("integration") {
|
||||
dimension = "test"
|
||||
applicationIdSuffix = ".integration"
|
||||
versionNameSuffix = "-integration"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
@ -38,3 +57,10 @@ android {
|
|||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// The orchestrator referenced by testOptions.execution above. The patrol
|
||||
// native library itself comes from the patrol pub package's android
|
||||
// module (a plugin subproject), not from a Maven artifact.
|
||||
androidTestUtil("androidx.test:orchestrator:1.5.1")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.app.smol_mail.integration;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import pl.leancode.patrol.PatrolJUnitRunner;
|
||||
|
||||
// The Patrol host class: each Dart test in the integration_test directory is
|
||||
// executed through this JUnit suite. Its package is the flavored applicationId
|
||||
// (com.app.smol_mail + .integration suffix); the namespace differs, so
|
||||
// MainActivity needs the explicit import below.
|
||||
@RunWith(Parameterized.class)
|
||||
public class MainActivityTest {
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Object[] testCases() {
|
||||
PatrolJUnitRunner instrumentation =
|
||||
(PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.setUp(com.example.smol_mail.MainActivity.class);
|
||||
instrumentation.waitForPatrolAppService();
|
||||
return instrumentation.listDartTests();
|
||||
}
|
||||
|
||||
public MainActivityTest(String dartTestName) {
|
||||
this.dartTestName = dartTestName;
|
||||
}
|
||||
|
||||
private final String dartTestName;
|
||||
|
||||
@Test
|
||||
public void runDartTest() {
|
||||
PatrolJUnitRunner instrumentation =
|
||||
(PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.runDartTest(dartTestName);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue