Giter VIP home page Giter VIP logo

Comments (2)

bartekpacia avatar bartekpacia commented on September 24, 2024

When I remove that seemingly rogue / from the last adb invocation in the script, I get:

05-08 22:05:39.785 30804 30804 E appproc : ERROR: could not find class 'am'
05-08 22:05:39.785 30804 30804 F app_process: thread.cc:2468] No pending exception expected: java.lang.ClassNotFoundException: am
05-08 22:05:39.785 30804 30804 F app_process: thread.cc:2468] (Throwable with empty stack trace)
05-08 22:05:39.785 30804 30804 F app_process: thread.cc:2468]
modified last part of the orchestrate.bash script
adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process androidx.test.services.shellexecutor.ShellMain \
    am instrument -w \
    -e targetInstrumentation com.example.android.testing.androidtestorchestratorsample.test/androidx.test.runner.AndroidJUnitRunner \
    -e clearPackageData true \
    androidx.test.orchestrator/.AndroidTestOrchestrator'

from testing-samples.

bartekpacia avatar bartekpacia commented on September 24, 2024

Ugh, I got the order wrong.

Good: app_process / androidx.test.services.shellexecutor.ShellMain
Bad: app_process androidx.test.services.shellexecutor.ShellMain /

This is the working version:

orchestrate.bash - working
#!/usr/bin/env bash
set -euo pipefail

# This script runs native JUnit tests with the Android Test Orchestrator.
# Adapted from:
# * https://developer.android.com/training/testing/instrumented-tests/androidx-test-libraries/runner#enable-command
# * https://stackoverflow.com/questions/63732977/how-to-use-android-test-orchestrator-in-command-line

VERSION="1.5.0-alpha01"

ORCHESTRATOR_APK_PATH="$HOME/Desktop/orchestrator.apk"
TEST_SERVICES_APK_PATH="$HOME/Desktop/test-services.apk"

if [ ! -f "$ORCHESTRATOR_APK_PATH" ]; then
	curl -o "$ORCHESTRATOR_APK_PATH" "https://dl.google.com/dl/android/maven2/androidx/test/orchestrator/$VERSION/orchestrator-$VERSION.apk" 2>/dev/null    
fi

if [ ! -f "$TEST_SERVICES_APK_PATH" ]; then
	curl -o "$TEST_SERVICES_APK_PATH" "https://dl.google.com/dl/android/maven2/androidx/test/services/test-services/$VERSION/test-services-$VERSION.apk" 2>/dev/null
fi

DEVICE_API_LEVEL="$(adb shell getprop ro.build.version.sdk)"

FORCE_QUERYABLE_OPTION=""
if [[ "$DEVICE_API_LEVEL" -ge 30 ]]; then
	FORCE_QUERYABLE_OPTION="--force-queryable"
fi

# uninstall old versions
adb uninstall androidx.test.services || true
adb uninstall androidx.test.orchestrator || true

# Install the test orchestrator.
adb install "$FORCE_QUERYABLE_OPTION" -r "$ORCHESTRATOR_APK_PATH"

# Install test services.
adb install "$FORCE_QUERYABLE_OPTION" -r "$TEST_SERVICES_APK_PATH"

# app_process spawns a new process
# Add "-e clearPackageData true" to clear your app's data in between runs.
adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process / androidx.test.services.shellexecutor.ShellMain \
    am instrument -w \
    -e targetInstrumentation com.example.android.testing.androidtestorchestratorsample.test/androidx.test.runner.AndroidJUnitRunner \
    -e clearPackageData true \
    androidx.test.orchestrator/.AndroidTestOrchestrator'

I realized this after I got curious about SpeakEasy, and found its README.

from testing-samples.

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.