Ejemplo n.º 1
0
    def generate(self, device: Device, package_name: str,
                 destination_file_name: str) -> TestCase:
        assert device.api_level() >= self.minimum_api

        verbose_level = RequiredFeature('verbose_level').request()
        start_time = time.time()

        self.prepare_device_for_run(device)

        evolutiz_events = settings.SEQUENCE_LENGTH_MAX
        test_case = []

        launch_result = self.evolutiz_connector.send_command(
            device, package_name, f"performview launch-app")

        for i in range(0, evolutiz_events):
            widget_action_result = WidgetAction.random(device,
                                                       self.evolutiz_connector)

            test_event: TestEvent = widget_action_result
            test_case.append(test_event)

            if widget_action_result.is_outbound():
                break

        if verbose_level > 0:
            logger.log_progress(
                f'\nEvolutiz test generation took: {time.time() - start_time:.2f} '
                f'seconds for {len(test_case):d} events')

        self.clean_device_after_run(device)

        return test_case
Ejemplo n.º 2
0
    def run(self, device: Device, package_name: str, script_name: str) -> None:
        assert device.api_level() >= self.minimum_api

        verbose_level = RequiredFeature('verbose_level').request()
        start_time = time.time()

        self.prepare_device_for_run(device)

        evolutiz_cmd = f"evolutiz -p {package_name} -v -v -v --throttle 200 --ignore-crashes " \
                       f"--ignore-security-exceptions --ignore-timeouts --bugreport -f /mnt/sdcard/{script_name} 1"

        output, errors, result_code = adb.shell_command(
            device, evolutiz_cmd, timeout=settings.TEST_CASE_EVAL_TIMEOUT)
        if verbose_level > 1:
            print(f"Test case running finished with output:\n{output}")

        if "Exception" in errors:
            device_stacktrace = errors.split("** Error: ")[1]
            raise Exception(
                f"An error occurred when running test case: {device_stacktrace}"
            )

        # need to manually kill evolutiz when timeout
        adb.pkill(device, "evolutiz")

        self.clean_device_after_run(device)

        if verbose_level > 0:
            logger.log_progress(
                f'\nEvolutiz test run took: {time.time() - start_time:.2f} seconds'
            )