public boolean run ( ) { otherApks . forEach ( otherApk -> { checkArgument ( otherApk . exists ( ) , "Could not find other APK: " + otherApk ) ; } ) ; checkArgument ( testApk . exists ( ) , "Could not find test APK: " + testApk ) ; AndroidDebugBridge adb = SpoonUtils . initAdb ( androidSdk , adbTimeout ) ; try { final SpoonInstrumentationInfo testInfo = parseFromFile ( testApk ) ; // If we were given an empty serial set, load all available devices. Set < String > serials = this . serials ; if ( serials . isEmpty ( ) ) { serials = SpoonUtils . findAllDevices ( adb , testInfo . getMinSdkVersion ( ) ) ; } if ( this . skipDevices != null && ! this . skipDevices . isEmpty ( ) ) { serials = new LinkedHashSet <> ( serials ) ; serials . removeAll ( this . skipDevices ) ; } if ( serials . isEmpty ( ) && ! allowNoDevices ) { throw new RuntimeException ( "No device(s) found." ) ; } // Execute all the things... SpoonSummary summary = runTests ( adb , serials , testInfo ) ; // ...and render to HTML new HtmlRenderer ( summary , SpoonUtils . GSON , output ) . render ( ) ; if ( codeCoverage ) { try { SpoonCoverageMerger . mergeCoverageFiles ( serials , output ) ; logDebug ( debug , "Merging of coverage files done." ) ; } catch ( IOException exception ) { throw new RuntimeException ( "Error while merging coverage files. " + "Did you set the \"testCoverageEnabled\" flag in your build.gradle?" , exception ) ; } } return parseOverallSuccess ( summary ) ; } finally { if ( terminateAdb ) { AndroidDebugBridge . terminate ( ) ; } } }
Install and execute the tests on all specified devices .