TF-2953 Set up Patrol tests

This commit is contained in:
DatDang
2024-10-11 11:58:09 +07:00
committed by Dat H. Pham
parent e8e709d63a
commit 25437ba92e
18 changed files with 437 additions and 18 deletions
+12 -1
View File
@@ -23,7 +23,7 @@ if (flutterVersionName == null) {
def flutterMinSdkVersion = localProperties.getProperty('flutter.minSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '19'
flutterMinSdkVersion = '21'
}
apply plugin: 'com.android.application'
@@ -54,6 +54,8 @@ android {
manifestPlaceholders = [
'appAuthRedirectScheme': 'teammail.mobile'
]
testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: "true"
}
compileOptions {
@@ -77,7 +79,15 @@ android {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
}
}
testOptions {
execution "ANDROIDX_TEST_ORCHESTRATOR"
}
}
flutter {
@@ -90,4 +100,5 @@ dependencies {
implementation 'androidx.work:work-runtime-ktx:2.7.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.window:window:1.0.0'
androidTestUtil "androidx.test:orchestrator:1.5.0"
}
@@ -0,0 +1,33 @@
package com.linagora.android.tmail;
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;
@RunWith(Parameterized.class)
public class MainActivityTest {
@Parameters(name = "{0}")
public static Object[] testCases() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
// replace "MainActivity.class" with "io.flutter.embedding.android.FlutterActivity.class"
// if your AndroidManifest is using: android:name="io.flutter.embedding.android.FlutterActivity"
instrumentation.setUp(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);
}
}