mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
runner: rename method name
This commit is contained in:
@@ -2,17 +2,16 @@
|
||||
import zmq
|
||||
import os
|
||||
from locust import HttpLocust, TaskSet, task
|
||||
from ate import testcase, runner, exception
|
||||
from ate import runner, exception
|
||||
|
||||
class WebPageTasks(TaskSet):
|
||||
def on_start(self):
|
||||
self.test_runner = runner.Runner(self.client)
|
||||
self.testset = self.locust.testset
|
||||
|
||||
@task
|
||||
def test_specified_scenario(self):
|
||||
try:
|
||||
self.test_runner.run_testset(self.testset)
|
||||
self.test_runner.run(self.locust.file_path)
|
||||
except exception.ValidationError:
|
||||
pass
|
||||
|
||||
@@ -22,4 +21,4 @@ class WebPageUser(HttpLocust):
|
||||
min_wait = 1000
|
||||
max_wait = 5000
|
||||
|
||||
testset = testcase.load_test_file("$TESTCASE_FILE")
|
||||
file_path = "$TESTCASE_FILE"
|
||||
|
||||
@@ -65,7 +65,7 @@ class Runner(object):
|
||||
|
||||
return parsed_request
|
||||
|
||||
def run_test(self, testcase):
|
||||
def _run_test(self, testcase):
|
||||
""" run single testcase.
|
||||
@param (dict) testcase
|
||||
{
|
||||
@@ -124,7 +124,7 @@ class Runner(object):
|
||||
|
||||
return True
|
||||
|
||||
def run_testset(self, testset, variables_mapping=None):
|
||||
def _run_testset(self, testset, variables_mapping=None):
|
||||
""" run single testset, including one or several testcases.
|
||||
@param
|
||||
(dict) testset
|
||||
@@ -168,7 +168,7 @@ class Runner(object):
|
||||
testcases = testset.get("testcases", [])
|
||||
for testcase in testcases:
|
||||
try:
|
||||
assert self.run_test(testcase)
|
||||
assert self._run_test(testcase)
|
||||
except AssertionError:
|
||||
success = False
|
||||
|
||||
@@ -195,7 +195,7 @@ class Runner(object):
|
||||
testsets = testcase.load_testcases_by_path(path)
|
||||
for testset in testsets:
|
||||
try:
|
||||
result = self.run_testset(testset, mapping)
|
||||
result = self._run_testset(testset, mapping)
|
||||
assert result["success"]
|
||||
except AssertionError:
|
||||
success = False
|
||||
|
||||
@@ -14,7 +14,7 @@ class ApiTestCase(unittest.TestCase):
|
||||
def runTest(self):
|
||||
""" run testcase and check result.
|
||||
"""
|
||||
self.assertTrue(self.test_runner.run_test(self.testcase))
|
||||
self.assertTrue(self.test_runner._run_test(self.testcase))
|
||||
|
||||
class ApiTestSuite(unittest.TestSuite):
|
||||
""" create test suite with a testset, it may include one or several testcases.
|
||||
|
||||
@@ -28,13 +28,13 @@ class TestRunner(ApiServerUnittest):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
testcases = utils.load_tests(testcase_file_path)
|
||||
testcase = testcases[0]["test"]
|
||||
self.assertTrue(self.test_runner.run_test(testcase))
|
||||
self.assertTrue(self.test_runner._run_test(testcase))
|
||||
|
||||
testcase = testcases[1]["test"]
|
||||
self.assertTrue(self.test_runner.run_test(testcase))
|
||||
self.assertTrue(self.test_runner._run_test(testcase))
|
||||
|
||||
testcase = testcases[2]["test"]
|
||||
self.assertTrue(self.test_runner.run_test(testcase))
|
||||
self.assertTrue(self.test_runner._run_test(testcase))
|
||||
|
||||
def test_run_single_testcase_fail(self):
|
||||
testcase = {
|
||||
@@ -63,12 +63,11 @@ class TestRunner(ApiServerUnittest):
|
||||
}
|
||||
|
||||
with self.assertRaises(exception.ValidationError):
|
||||
self.test_runner.run_test(testcase)
|
||||
self.test_runner._run_test(testcase)
|
||||
|
||||
def test_run_testset_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
testset = testcase.load_test_file(testcase_file_path)
|
||||
result = self.test_runner.run_testset(testset)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testsets_hardcode(self):
|
||||
@@ -79,15 +78,13 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_run_testset_template_variables(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
testset = testcase.load_test_file(testcase_file_path)
|
||||
result = self.test_runner.run_testset(testset)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testset_template_import_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_template_import_functions.yml')
|
||||
testset = testcase.load_test_file(testcase_file_path)
|
||||
result = self.test_runner.run_testset(testset)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testsets_template_import_functions(self):
|
||||
@@ -111,18 +108,16 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_run_testset_output(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
testset = testcase.load_test_file(testcase_file_path)
|
||||
result = self.test_runner.run_testset(testset)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
self.assertIn("token", result["output"])
|
||||
|
||||
def test_run_testset_with_variables_mapping(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
testset = testcase.load_test_file(testcase_file_path)
|
||||
variables_mapping = {
|
||||
"app_version": '2.9.7'
|
||||
}
|
||||
result = self.test_runner.run_testset(testset, variables_mapping)
|
||||
result = self.test_runner.run(testcase_file_path, variables_mapping)
|
||||
self.assertTrue(result["success"])
|
||||
self.assertIn("token", result["output"])
|
||||
|
||||
Reference in New Issue
Block a user