Added test-list option to run-ui-tests (#4540)
* Added test-list option to run-ui-tests will help bifurcating the ui tests into stages * modified to add new parameters at the end
This commit is contained in:
parent
cfb34ca5d6
commit
d746d1e8af
3 changed files with 21 additions and 9 deletions
|
|
@ -328,9 +328,10 @@ def run_tests(context, app=None, module=None, doctype=None, test=(),
|
|||
@click.command('run-ui-tests')
|
||||
@click.option('--app', help="App to run tests on, leave blank for all apps")
|
||||
@click.option('--test', help="Path to the specific test you want to run")
|
||||
@click.option('--test-list', help="Path to the txt file with the list of test cases")
|
||||
@click.option('--profile', is_flag=True, default=False)
|
||||
@pass_context
|
||||
def run_ui_tests(context, app=None, test=False, profile=False):
|
||||
def run_ui_tests(context, app=None, test=False, test_list=False, profile=False):
|
||||
"Run UI tests"
|
||||
import frappe.test_runner
|
||||
|
||||
|
|
@ -338,7 +339,7 @@ def run_ui_tests(context, app=None, test=False, profile=False):
|
|||
frappe.init(site=site)
|
||||
frappe.connect()
|
||||
|
||||
ret = frappe.test_runner.run_ui_tests(app=app, test=test, verbose=context.verbose,
|
||||
ret = frappe.test_runner.run_ui_tests(app=app, test=test, test_list=test_list, verbose=context.verbose,
|
||||
profile=profile)
|
||||
if len(ret.failures) == 0 and len(ret.errors) == 0:
|
||||
ret = 0
|
||||
|
|
|
|||
|
|
@ -144,13 +144,16 @@ def run_tests_for_module(module, verbose=False, tests=(), profile=False):
|
|||
def run_setup_wizard_ui_test(app=None, verbose=False, profile=False):
|
||||
'''Run setup wizard UI test using test_test_runner'''
|
||||
frappe.flags.run_setup_wizard_ui_test = 1
|
||||
return run_ui_tests(app, None, verbose, profile)
|
||||
return run_ui_tests(app=app, test=None, verbose=verbose, profile=profile)
|
||||
|
||||
def run_ui_tests(app=None, test=None, verbose=False, profile=False):
|
||||
def run_ui_tests(app=None, test=None, test_list=None, verbose=False, profile=False):
|
||||
'''Run a single unit test for UI using test_test_runner'''
|
||||
module = importlib.import_module('frappe.tests.ui.test_test_runner')
|
||||
frappe.flags.ui_test_app = app
|
||||
frappe.flags.ui_test_path = test
|
||||
if test_list:
|
||||
frappe.flags.ui_test_list = test_list
|
||||
else:
|
||||
frappe.flags.ui_test_path = test
|
||||
return _run_unittest(module=module, verbose=verbose, tests=(), profile=profile)
|
||||
|
||||
def _run_unittest(module, verbose=False, tests=(), profile=False):
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ def get_tests():
|
|||
'''Get tests base on flag'''
|
||||
frappe.db.set_value('Test Runner', None, 'app', frappe.flags.ui_test_app or '')
|
||||
|
||||
if frappe.flags.ui_test_path:
|
||||
if frappe.flags.ui_test_list:
|
||||
# list of tests
|
||||
return get_tests_for(test_list=frappe.flags.ui_test_list)
|
||||
elif frappe.flags.ui_test_path:
|
||||
# specific test
|
||||
return (frappe.flags.ui_test_path,)
|
||||
elif frappe.flags.ui_test_app:
|
||||
|
|
@ -64,10 +67,15 @@ def get_tests():
|
|||
tests.extend(get_tests_for(app))
|
||||
return tests
|
||||
|
||||
def get_tests_for(app):
|
||||
'''Get all tests for a particular app'''
|
||||
def get_tests_for(app=None, test_list=None):
|
||||
tests = []
|
||||
tests_path = frappe.get_app_path(app, 'tests', 'ui', 'tests.txt')
|
||||
if test_list:
|
||||
# Get all tests from a particular txt file
|
||||
app, test_list = test_list.split(os.path.sep, 1)
|
||||
tests_path = frappe.get_app_path(app, test_list)
|
||||
else:
|
||||
# Get all tests for a particular app
|
||||
tests_path = frappe.get_app_path(app, 'tests', 'ui', 'tests.txt')
|
||||
if os.path.exists(tests_path):
|
||||
with open(tests_path, 'r') as fileobj:
|
||||
tests = fileobj.read().strip().splitlines()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue