rename testset => testcase

This commit is contained in:
debugtalk
2018-10-02 23:56:16 +08:00
parent c440dbeb7a
commit 968fdc3b01
20 changed files with 86 additions and 68 deletions

View File

@@ -1,5 +1,5 @@
- config:
name: "user management testset."
name: "user management testcase."
parameters:
- user_agent: ["iOS/10.1", "iOS/10.2", "iOS/10.3"]
- username-password:

View File

@@ -1,5 +1,5 @@
- config:
name: "create user testsets."
name: "create user testcases."
variables:
- user_agent: 'iOS/10.3'
- device_sn: ${gen_random_string(15)}

View File

@@ -1,5 +1,5 @@
- config:
name: "user management testset."
name: "user management testcase."
variables:
- user_agent: 'iOS/10.3'
- device_sn: ${gen_random_string(15)}

View File

@@ -1,5 +1,5 @@
- config:
name: "create user testsets."
name: "create user testcases."
variables:
- device_sn: 'HZfFBh6tU59EdXJ'
request:

View File

@@ -11,12 +11,12 @@ from tests.base import ApiServerUnittest
class TestHttpRunner(ApiServerUnittest):
def setUp(self):
self.testcase_cli_path = "tests/data/demo_testset_cli.yml"
self.testcase_cli_path = "tests/data/demo_testcase_cli.yml"
self.testcase_file_path_list = [
os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.yml'),
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml'),
os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
]
self.testcases = [{
'config': {
@@ -273,21 +273,21 @@ class TestHttpRunner(ApiServerUnittest):
def test_run_testcase_template_variables(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_variables.yml')
os.getcwd(), 'tests/data/demo_testcase_variables.yml')
runner = HttpRunner().run(testcase_file_path)
summary = runner.summary
self.assertTrue(summary["success"])
def test_run_testcase_template_import_functions(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_functions.yml')
os.getcwd(), 'tests/data/demo_testcase_functions.yml')
runner = HttpRunner().run(testcase_file_path)
summary = runner.summary
self.assertTrue(summary["success"])
def test_run_testcase_layered(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_layer.yml')
os.getcwd(), 'tests/data/demo_testcase_layer.yml')
runner = HttpRunner().run(testcase_file_path)
summary = runner.summary
self.assertTrue(summary["success"])
@@ -295,7 +295,7 @@ class TestHttpRunner(ApiServerUnittest):
def test_run_testcase_output(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_layer.yml')
os.getcwd(), 'tests/data/demo_testcase_layer.yml')
runner = HttpRunner(failfast=True).run(testcase_file_path)
summary = runner.summary
self.assertTrue(summary["success"])
@@ -304,7 +304,7 @@ class TestHttpRunner(ApiServerUnittest):
def test_run_testcase_with_variables_mapping(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_layer.yml')
os.getcwd(), 'tests/data/demo_testcase_layer.yml')
variables_mapping = {
"app_version": '2.9.7'
}

View File

@@ -64,7 +64,7 @@ class TestFileLoader(unittest.TestCase):
def test_load_json_testcases(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
testcases = loader.load_file(testcase_file_path)
self.assertEqual(len(testcases), 3)
test = testcases[0]["test"]
@@ -75,7 +75,7 @@ class TestFileLoader(unittest.TestCase):
def test_load_yaml_testcases(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.yml')
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml')
testcases = loader.load_file(testcase_file_path)
self.assertEqual(len(testcases), 3)
test = testcases[0]["test"]
@@ -404,7 +404,7 @@ class TestSuiteLoader(unittest.TestCase):
# absolute file path
path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
testcases_list = loader.load_tests(path)
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
@@ -415,7 +415,7 @@ class TestSuiteLoader(unittest.TestCase):
self.assertIn("get_sign", testcases_list[0]["config"]["refs"]["debugtalk"]["functions"])
# relative file path
path = 'tests/data/demo_testset_hardcode.yml'
path = 'tests/data/demo_testcase_hardcode.yml'
testcases_list = loader.load_tests(path)
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
@@ -427,8 +427,8 @@ class TestSuiteLoader(unittest.TestCase):
# list/set container with file(s)
path = [
os.path.join(os.getcwd(), 'tests/data/demo_testset_hardcode.json'),
'tests/data/demo_testset_hardcode.yml'
os.path.join(os.getcwd(), 'tests/data/demo_testcase_hardcode.json'),
'tests/data/demo_testcase_hardcode.yml'
]
testcases_list = loader.load_tests(path)
self.assertEqual(len(testcases_list), 2)
@@ -447,21 +447,21 @@ class TestSuiteLoader(unittest.TestCase):
def test_load_testcases_by_path_folder(self):
# absolute folder path
path = os.path.join(os.getcwd(), 'tests/data')
testset_list_1 = loader.load_tests(path)
self.assertGreater(len(testset_list_1), 4)
testcase_list_1 = loader.load_tests(path)
self.assertGreater(len(testcase_list_1), 4)
# relative folder path
path = 'tests/data/'
testset_list_2 = loader.load_tests(path)
self.assertEqual(len(testset_list_1), len(testset_list_2))
testcase_list_2 = loader.load_tests(path)
self.assertEqual(len(testcase_list_1), len(testcase_list_2))
# list/set container with file(s)
path = [
os.path.join(os.getcwd(), 'tests/data'),
'tests/data/'
]
testset_list_3 = loader.load_tests(path)
self.assertEqual(len(testset_list_3), 2 * len(testset_list_1))
testcase_list_3 = loader.load_tests(path)
self.assertEqual(len(testcase_list_3), 2 * len(testcase_list_1))
def test_load_testcases_by_path_not_exist(self):
# absolute folder path
@@ -484,7 +484,7 @@ class TestSuiteLoader(unittest.TestCase):
def test_load_testcases_by_path_layered(self):
path = os.path.join(
os.getcwd(), 'tests/data/demo_testset_layer.yml')
os.getcwd(), 'tests/data/demo_testcase_layer.yml')
testcases_list = loader.load_tests(path)
self.assertIn("variables", testcases_list[0]["config"])
self.assertIn("request", testcases_list[0]["config"])

View File

@@ -380,7 +380,7 @@ class TestParser(unittest.TestCase):
{"app_version": "${gen_app_version()}"},
{"username-password": "${get_account()}"}
]
testset_path = os.path.join(
testcase_path = os.path.join(
os.getcwd(),
"tests/data/demo_parameters.yml"
)
@@ -425,7 +425,7 @@ class TestParser(unittest.TestCase):
]
variables_mapping = {}
functions_mapping = project_mapping["debugtalk"]["functions"]
testset_path = os.path.join(
testcase_path = os.path.join(
os.getcwd(),
"tests/data/demo_parameters.yml"
)

View File

@@ -27,9 +27,9 @@ class TestRunner(ApiServerUnittest):
def test_run_single_testcase(self):
testcase_file_path_list = [
os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.yml'),
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml'),
os.path.join(
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
]
for testcase_file_path in testcase_file_path_list:
@@ -76,7 +76,7 @@ class TestRunner(ApiServerUnittest):
with self.assertRaises(exceptions.ValidationFailure):
self.test_runner.run_test(test)
def test_run_testset_with_hooks(self):
def test_run_testcase_with_hooks(self):
start_time = time.time()
config_dict = {
@@ -117,17 +117,17 @@ class TestRunner(ApiServerUnittest):
}
test_runner = runner.Runner(config_dict)
end_time = time.time()
# check if testset setup hook executed
# check if testcase setup hook executed
self.assertGreater(end_time - start_time, 0.5)
start_time = time.time()
test_runner.run_test(test)
test_runner.run_test(test)
end_time = time.time()
# testset teardown hook has not been executed now
# testcase teardown hook has not been executed now
self.assertLess(end_time - start_time, 1)
def test_run_testset_with_hooks_modify_request(self):
def test_run_testcase_with_hooks_modify_request(self):
config_dict = {
"name": "basic test with httpbin",
"variables": self.debugtalk_module["variables"],
@@ -161,7 +161,7 @@ class TestRunner(ApiServerUnittest):
test_runner = runner.Runner(config_dict)
test_runner.run_test(test)
def test_run_testset_with_teardown_hooks_success(self):
def test_run_testcase_with_teardown_hooks_success(self):
test = {
"name": "get token",
"request": {
@@ -192,7 +192,7 @@ class TestRunner(ApiServerUnittest):
# check if teardown function executed
self.assertLess(end_time - start_time, 0.5)
def test_run_testset_with_teardown_hooks_fail(self):
def test_run_testcase_with_teardown_hooks_fail(self):
test = {
"name": "get token",
"request": {
@@ -226,10 +226,10 @@ class TestRunner(ApiServerUnittest):
def test_run_testcase_with_empty_header(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/test_bugfix.yml')
testsets = loader.load_tests(testcase_file_path)
testset = testsets[0]
config_dict_headers = testset["config"]["request"]["headers"]
test_dict_headers = testset["teststeps"][0]["request"]["headers"]
testcases = loader.load_tests(testcase_file_path)
testcase = testcases[0]
config_dict_headers = testcase["config"]["request"]["headers"]
test_dict_headers = testcase["teststeps"][0]["request"]["headers"]
headers = deep_update_dict(
config_dict_headers,
test_dict_headers