示例#1
0
    def run(self):
        """
        run tester to capture logcat, start App TestRunner instance, get launch time, filter exceptions in app log
        and generate test report

        @return: number of failed testcases
        @rtype: integer
        """
        self.__reset()
        self.start_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))

        # 2014-07-22, capture logcat in ASYNC mode
        printLog("Start capture adb logcat ...")
        # redirect to local drive would generate error: /system/bin/sh: can't create logcat.log: Read-only file system
        # using the android file system path would solve the problem
        # child = Popen(['adb', 'logcat', '>', '/data/data/%s' % ADBLOG_FILE])
        child = Popen("adb logcat 2>&1 > %s" % ADBLOG_FILE, shell=True)
        # truncate file after 3 seconds to get rid of old logs
        time.sleep(3)
        self.shell.truncate_file(ADBLOG_FILE)
        try:
            tr = AppTestRunner(self.test_buildnum, self.testPool, self.device)
            tr.run()
        except (AssertionError, EnvironmentError), e:
            printLog("Failed to initialize test runner {}: \n{}".format(self.device.deviceId, e.message), logging.ERROR)
            return -1
示例#2
0
 def run(self, tc_file_path):
     tr = AppTestRunner(10, TestCasePool.factory([TestCase.fromFile(tc_file_path)]), TestDevice(self.serial_no))
     tr.run()