Beispiel #1
0
    def __init__(self, suite=DEFAULT_TEST_SUITE, buildnum=0):
        """
        constructor.
        """

        self.test_buildnum = buildnum
        """ the build number to verify """
        self.test_suite = suite
        """ the suite to test"""

        self.Pass = 0
        """ Passed testcase number"""
        self.Fail = 0
        """ failed testcase number """
        self.Total = 0
        """ total testcase number """
        self.ALTList = []
        """ activity launch time list """
        self.exception_map_list = [{}, {}]
        """ app exception map list: one keeps formulated exceptions and the other keeps raw exceptions """
        self.start_time = None
        """ test start time"""
        self.end_time = None
        """ test finish time"""
        self.shell = Shell()
        """ Shell object """
        # do environment validation
        if not path.isdir(TC_DIR):
            print ("Required directory %s does not exist. please check and run again." % TC_DIR)
            return
        if not path.isdir(TS_DIR):
            print ("Required directory %s does not exist. please check and run again." % TS_DIR)
            return
        if not path.isdir(SNAPSHOT_DIR):
            mkdir(SNAPSHOT_DIR)
        # remove old log file
        if path.isfile(TESTER_DEBUG_LOG_FILE):
            if Tester.DEBUG == logging.DEBUG:
                print ("Removing old log file...")
            remove(TESTER_DEBUG_LOG_FILE)
        # truncate_file(TESTER_DEBUG_LOG_FILE)

        # create new log file
        # Oct 21: need to assign a different logger id each time, otherwise it will use the existing one
        # which will be closed at the end of run()
        self.logHandler = createLogger(Tester.DEBUG)
        """ log file handler """
        # get device, by default get the connected Genymotion device
        self.device = None
        self.device = TestDevicePool().getDevice()  # make='Genymotion')
        """ test device """
        if self.device is None:
            raise EnvironmentError("[Tester] NO DEVICE OR MORE THAN ONE DEVICE FOUND. QUIT.")

        if Tester.DEBUG == logging.DEBUG:
            printLog("[Tester] FOUND DEVICE.", logging.DEBUG)

        if Tester.GET_BUILD:
            if not self.getBuild():
                raise EnvironmentError("[Tester] Get build failed.")
        # build testcase pool
        self.testPool = TestCasePool.fromSuite(self.test_suite)
        """ testcase pool for current test run """
        if len(self.testPool) == 0:
            raise EnvironmentError("[Tester] NO TESTCASE IN THE TEST SUITE. QUIT.")
 def run(self, tc_file_path):
     tr = AppTestRunner(10, TestCasePool.factory([TestCase.fromFile(tc_file_path)]), TestDevice(self.serial_no))
     tr.run()