
# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    run.py                                             :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: ray <liujinjia@testerlife.com>             +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2017/05/31 15:36:01 by jinjialiu         #+#    #+#              #
#    Updated: 2017/05/31 15:37:20 by ray              ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

import time
import unittest

from app.config import config
from app.constructor.create_case import CreateCase
from app.constructor.use_case_operation import UseCaseOperation
from app.controller.util import BSTestRunner
from app.controller.util.xtest import TestReport, dict_encode_test_results

CASE_PATH = CreateCase.create_unittest_files().get('case_path')
REPORT_PATH = 'app/report/report.html'


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()  # 测试启动的时刻点
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)  # 运行测试套件，并返回测试结果
        total_time = time.time() - start_time  # 测试过程整体的耗时
        test_res_dict = dict_encode_test_results(
            test_result,
            run_time=total_time,
            pro_version='1.0'  # 当前被测试的系统的版本号,依据目前系统的信息，如果服务端提供接口，则可以做成自动化的
        )
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(
                files,
                title='TestReport_{0}'.format(int(time.time())),
                description=u'自动化生成用例测试'
            )
            runner.run(suite)

if __name__ == '__main__':
    try:
        unittest.main()
    except TypeError:
        UseCaseOperation.clear_test_data()

e4ef697e46a3a6616bea8e202563fd6c40537c40
<mask token>


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)
        total_time = time.time() - start_time
        test_res_dict = dict_encode_test_results(test_result, run_time=
            total_time, pro_version='1.0')
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(files, title=
                'TestReport_{0}'.format(int(time.time())), description=
                u'自动化生成用例测试')
            runner.run(suite)


<mask token>

<mask token>


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)
        total_time = time.time() - start_time
        test_res_dict = dict_encode_test_results(test_result, run_time=
            total_time, pro_version='1.0')
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(files, title=
                'TestReport_{0}'.format(int(time.time())), description=
                u'自动化生成用例测试')
            runner.run(suite)


if __name__ == '__main__':
    try:
        unittest.main()
    except TypeError:
        UseCaseOperation.clear_test_data()

<mask token>
CASE_PATH = CreateCase.create_unittest_files().get('case_path')
REPORT_PATH = 'app/report/report.html'


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)
        total_time = time.time() - start_time
        test_res_dict = dict_encode_test_results(test_result, run_time=
            total_time, pro_version='1.0')
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(files, title=
                'TestReport_{0}'.format(int(time.time())), description=
                u'自动化生成用例测试')
            runner.run(suite)


if __name__ == '__main__':
    try:
        unittest.main()
    except TypeError:
        UseCaseOperation.clear_test_data()

import time
import unittest
from app.config import config
from app.constructor.create_case import CreateCase
from app.constructor.use_case_operation import UseCaseOperation
from app.controller.util import BSTestRunner
from app.controller.util.xtest import TestReport, dict_encode_test_results
CASE_PATH = CreateCase.create_unittest_files().get('case_path')
REPORT_PATH = 'app/report/report.html'


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)
        total_time = time.time() - start_time
        test_res_dict = dict_encode_test_results(test_result, run_time=
            total_time, pro_version='1.0')
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(files, title=
                'TestReport_{0}'.format(int(time.time())), description=
                u'自动化生成用例测试')
            runner.run(suite)


if __name__ == '__main__':
    try:
        unittest.main()
    except TypeError:
        UseCaseOperation.clear_test_data()


# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    run.py                                             :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: ray <liujinjia@testerlife.com>             +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2017/05/31 15:36:01 by jinjialiu         #+#    #+#              #
#    Updated: 2017/05/31 15:37:20 by ray              ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

import time
import unittest

from app.config import config
from app.constructor.create_case import CreateCase
from app.constructor.use_case_operation import UseCaseOperation
from app.controller.util import BSTestRunner
from app.controller.util.xtest import TestReport, dict_encode_test_results

CASE_PATH = CreateCase.create_unittest_files().get('case_path')
REPORT_PATH = 'app/report/report.html'


def load_tests(loader, tests, pattern):
    """
    Discover and load all unit tests in all files named
    ``test_*.py`` in ./src/app/
    """
    start_time = time.time()  # 测试启动的时刻点
    suite = unittest.defaultTestLoader.discover(CASE_PATH, pattern='test_*.py')
    if config.SWITCH:
        test_result = unittest.TextTestRunner().run(suite)  # 运行测试套件，并返回测试结果
        total_time = time.time() - start_time  # 测试过程整体的耗时
        test_res_dict = dict_encode_test_results(
            test_result,
            run_time=total_time,
            pro_version='1.0'  # 当前被测试的系统的版本号,依据目前系统的信息，如果服务端提供接口，则可以做成自动化的
        )
        test_report = TestReport()
        auth_res = test_report.get_api_auth()
        if auth_res:
            test_report.post_unit_test_data(test_res_dict)
        else:
            raise PermissionError('auth error...')
    else:
        with open(REPORT_PATH, 'wb') as files:
            runner = BSTestRunner.BSTestRunner(
                files,
                title='TestReport_{0}'.format(int(time.time())),
                description=u'自动化生成用例测试'
            )
            runner.run(suite)

if __name__ == '__main__':
    try:
        unittest.main()
    except TypeError:
        UseCaseOperation.clear_test_data()
