4

Per my work-around here ./gradlew test connectedAndroidTest erases my getFilesDir() folder, I test on two ONN tablets using a Ruby Rakefile that looks a little bit like this:

task default: [ :unit_test_and_install, :espresso_test ]

task :unit_test_and_install do
    sh './gradlew --console=verbose test installDebug installDebugAndroidTest'
end

task :espresso_test do
    devices = `adb devices`
    serial_numbers = devices.split("\n")[1..-1].map{|q| q.split("\t")[0] }

    threads = serial_numbers.map do |sn|
        Thread.new do
            sh "adb -s #{sn} shell am instrument -w -r -e package com.mycorp.myapp -e disableAnalytics true " +
                    "com.mycorp.myapp.test/androidx.test.runner.AndroidJUnitRunner | tee tests_#{sn}.txt"
        end
    end

    threads.each &:join

    serial_numbers.each do |sn|
        grop = `grep "^OK .*tests" tests_#{sn}.txt`

        if grop == ''
            sh "cat tests_#{sn}.txt"
            abort 'FAILURES on ' + sn
        end
    end

end

The problem is the adb -s WHATEVER shell am instrument line. Even though it launches the JUnit tests correctly, sometimes the tablet puts up its "Allow USB debugging?" requester. (The one that says "The computer's RSA key fingerprint is...")

The tests run whether I tap the requester or not, and it usually does not pop up. Test runs and debugging runs from Android Studio or ./gradlew don't trigger the popup. But how do I get rid of it?

3
  • 2
    does the fingerprint change each time the dialog is shown? Please note that development questions are off-topic here.
    – Robert
    Feb 20, 2020 at 18:28
  • this is just initial pop up for each new host, should not happen. adb does generate new keys in .android under certain circumstances in home folder, maybe you did run your tests from different users? in any case you should grep connection state and wait for authorize in your script. if you want to skip this you need to modify devices ro.adb.secure
    – alecxs
    Feb 20, 2020 at 18:34
  • please stop editing this question. This is not wikipedia, Third parties should only edit a question to fix a typographical error or something
    – Phlip
    Apr 12, 2023 at 16:20

0

You must log in to answer this question.

Browse other questions tagged .