GithubHelp home page GithubHelp logo

Comments (7)

jBorkowska avatar jBorkowska commented on September 3, 2024

Hi @hanna-ho, I see in the logs that test report was generated: See the report at: . Could you send screenshots of this report? (it consists of multiple files) There could be more info on why the test failed.

In logs you provided I see also that no tests were found - it may be caused by mistakes in the native config. Please check (or post) the android/app/build.gradle file first

from patrol.

hanna-ho avatar hanna-ho commented on September 3, 2024

Hi there,
The report doesn't say much, at least to me.
image

The build.gradle file looks like this:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace "com.example.eudi_wallet"
    compileSdkVersion 34
    // compileSdkVersion 33
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    configurations {
        all {
            exclude group: 'com.scottyab', module: 'rootbeer-lib'
        }
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        //applicationId "com.example.eudi_wallet"
        applicationId "hu.egroup.ewc"

        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 26
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: "true"
    }

    signingConfigs {
        debug {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            shrinkResources false
            signingConfig signingConfigs.debug
        }
    }

    testOptions {
        execution "ANDROID_TEST_ORCHESTRATOR"
    }

    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    androidTestUtil "androidx.test:orchestrator:1.4.2"
}

from patrol.

jBorkowska avatar jBorkowska commented on September 3, 2024

Thanks for the report, unfortunately it says the same as logs.

Oops, I asked for build.gradle, but I was thinking MainActivityTest.java file - the one that you create in the setup tutorial. Sorry for confusion
In this MainActivityTest.java the very first line of it should be changed - the package name should be your package name, not the example one. Skipping this step may cause behaviour you described

from patrol.

hanna-ho avatar hanna-ho commented on September 3, 2024

Thanks for the idea, and the quick reply.
I have checked, the package name was set the same as the applicationId in the build.gradle.

package hu.egroup.ewc;

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 in AndroidManifest.xml in manifest/application/activity you have
        //     android:name="io.flutter.embedding.android.FlutterActivity"
        // instrumentation.setUp(MainActivity.class);
        instrumentation.setUp(io.flutter.embedding.android.FlutterActivity.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);
    }
}

from patrol.

jBorkowska avatar jBorkowska commented on September 3, 2024
        // if in AndroidManifest.xml in manifest/application/activity you have
        //     android:name="io.flutter.embedding.android.FlutterActivity"
        // instrumentation.setUp(MainActivity.class);
        instrumentation.setUp(io.flutter.embedding.android.FlutterActivity.class);

Did you try switching to the original line here? If yes and it still doesn't work, please post AndroidManifest.xml file

from patrol.

hanna-ho avatar hanna-ho commented on September 3, 2024

Yes I tried, I got an error:
cannot find symbol instrumentation.setUp(MainActivity.class);
symbol: class MainActivity
location: class MainActivityTest

My android manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.USE_BIOMETRIC"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.NFC" />

    <application
        android:label="MyD"
        android:name="${applicationName}"
        android:icon="@drawable/myd"
        tools:replace="android:label">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <!--TODO:  Add this filter, if you want support opening files into your app-->
     <!--       <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:mimeType="application/pdf"
                    android:scheme="content" />
            </intent-filter>-->
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/pdf" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="egroup.hu" />
                <data android:scheme="https"/>
                <data android:pathPattern="/eudiwallet"/>
               <!-- <data android:scheme="https"
                    android:host="ewc-cont"/>
                <data android:scheme="ewc-cont"
                    android:host="eudiwallet"/>
                <data android:scheme="https"
                    android:host="ewc-start"/>
                <data android:scheme="ewc-start"
                    android:host="eudiwallet"/>-->

            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

from patrol.

jBorkowska avatar jBorkowska commented on September 3, 2024

Sorry for late response.
In your manifest, the android:name property is .MainActivity, so you should leave the original line in MainActivityTest.java:
instrumentation.setUp(MainActivity.class);

The problem must be caused by something else. It would be great if you could send us a project, where this problem occurs. My guess right now is that the file structure in android/app/src/main is different than it should be

from patrol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.