[https://patrol.leancode.co/documentation][1]
Для установки Patrol CLI выполните следующие команды:
Код: Выделить всё
flutter pub global activate patrol_cli
patrol doctor
flutter pub add patrol --dev
patrol: ^latest_version
patrol:
app_name: App
android:
имя_пакета: com.ziing.app
Создал тестовый файл MainActivityTest.java в разделе android/app/src/androidTest/java/com/ziing/app/:
Код: Выделить всё
package com.ziing.app;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import pl.leancode.patrol.PatrolJUnitRunner;
@RunWith(Parameterized.class)
public class MainActivityTest {
@Parameterized.Parameters(name = "{0}")
public static Object[] testCases() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
instrumentation.setUp(MainActivity.class);
instrumentation.waitForPatrolAppService();
return instrumentation.listDartTests();
}
private final String dartTestName;
public MainActivityTest(String dartTestName) {
this.dartTestName = dartTestName;
}
@Test
public void runDartTest() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
instrumentation.runDartTest(dartTestName);
}
}
testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
testInstrumentationRunnerArguments ClearPackageData: "true"
Добавлено это в раздел Android:
gradle
Код: Выделить всё
testOptions {
execution "ANDROIDX_TEST_ORCHESTRATOR"
}
gradle
Код: Выделить всё
androidTestUtil "androidx.test:orchestrator:1.5.1"
Отсутствует импорт:
р>
Код: Выделить всё
package pl.leancode.patrol does not exist
package androidx.test.platform.app does not exist
package org.junit does not exist
Проверенные зависимости: я проверил, что все зависимости (Patrol, AndroidX Test, JUnit) правильно добавлены в build.gradle и pubspec.yaml. файлы.
Проект перестроен: очищен и перестроен проект, но ошибки сохраняются.
Синхронизирован Gradle: запустил flutter pub get и повторно синхронизировал Проект Gradle.
Очистка Flutter: выполнил очистку Flutter, а затем попытался пересобрать проект.
Запрос на помощь
Подробнее здесь: https://stackoverflow.com/questions/793 ... t-and-pack