Native app test in Android by CodeseptJS-Appium

Hi, I want to create a test case for native application in Android.

I have an apk, but if I specify the corresponding local folder in codecept.conf.js, the existing input data disappears and the desired test cannot be performed.

The test is new installing to Android?
How to set the app location in Android direct?

My Environment
macOS Catalina 10.15.4
Appium 1.15.1 (application)
node 13.12.0(can use 8)
codeceptJS 2.6.1
Android 7
Original Android machine
Original APK (no-uploaded store)

codecept.conf.js
exports.config = {
tests: ‘VisualTesting_xxx_main.js’,
output: ‘./output’,
helpers: {
Appium: {
app:
“/Users/admin/Desktop/CodeceptJS/appium/apk/com.xxx.mobile.igreenxxxdevicee_Launcher_20200417.apk”,
platform: “Android”,
desiredCapabilities: {
platformName: “Android”,
deviceName: “xxxxxx”, #Original Device Name
platformVersion: “7”,
automationName: “Appium”,
}
}
},
include: {
I: ‘./steps_file.js’,
},
bootstrap: null,
mocha: {},
name: ‘appium’,
translation: ‘ja-JP’,
plugins: {
retryFailedStep: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}

Try to move the app property into desiredCapabilities
This is my config:

...
helpers: {
    Appium: {
        platform: "Android",
        waitForTimeout: 20000,
        smartWait: 20000,
        device: "emulator",
        desiredCapabilities: {
            app: "http://192.168.10.133/SPORK-new.apk",
            appWaitActivity: "com.spork.android.controllers.activities.ProvisioningMain",
            platformName: "Android",
            platformVersion: "8.1",
            autoGrantPermissions: true,
            noReset: true,
            adbExecTimeout: 120000,
            noSign: true
        }
    }
    ...
}
...

When I run any test, at first the APK is installed. Note that Android app’s activity must match appWaitActivity otherwise test fails.
More details on http://appium.io/docs/en/writing-running-appium/caps/

thanks, I will test to set apk on local network.
should I set the property from Android network IP, and APK name only? or find APK folder by $adb shell pm list packages -f | grep <xxx.apk>?

Is there a way to test the installed APK directly?
I am not able to get APK from developers always, and if new installing APK is mandatory, I have to create restore procedure all the settings such as tools to be installed at the beginning of the test case.

Haven’t tried it, but absolute path to local folder with APK (to be reachable by Appium) should be working: https://codecept.io/helpers/Appium.html#helper-configuration.

I think that installation of APK is mandatory. Appium helper has the method I.installApp, but I’m using it only for test of upgrade (original APK must be installed based on config file)

Automatic running of my tests is handled by a Jenkins job. When new APK is built (or when I run the job), the job starts an emulator from Android Studio (e.g. /home/autotest/Android/Sdk/emulator/emulator @Nexus_9_API_27 -read-only) and then run CodeceptJS tests (npx codeceptjs run --debug, I have 3 tests). When the tests finish, the job kills the emulator. Ideally the emulator should be started before each test (to have always same clear environment for every test), but so far I didn’t have issue with my simple setup.

thanks, So should I use a mirroring tool and OS automation…?

I check the helper configuration.
but don’t know why it is set appPackage: "com.example.android.myApp".
for example, package:/data/app/com.xxx.mobile.device-1/base.apk=com.xxx.mobile.device by adb request, “com.xxx.mobile.device”?