mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 22:57:36 +08:00
refactor: make test runner unified
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import time
|
||||
|
||||
from httprunner import exception, runner, testcase, utils
|
||||
from httprunner.cli import run_suite_path
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
|
||||
@@ -77,50 +78,49 @@ class TestRunner(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(testcase_file_path)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testsets_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(self.testcase_file_path_list)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testset_template_variables(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(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')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(testcase_file_path)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testsets_template_import_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_template_import_functions.yml')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(testcase_file_path)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testsets_template_lambda_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_template_lambda_functions.yml')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(testcase_file_path)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testset_layered(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
result = run_suite_path(testcase_file_path)
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testset_output(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
self.assertIn("token", result["output"])
|
||||
result = run_suite_path(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(
|
||||
@@ -128,9 +128,9 @@ class TestRunner(ApiServerUnittest):
|
||||
variables_mapping = {
|
||||
"app_version": '2.9.7'
|
||||
}
|
||||
result = self.test_runner.run(testcase_file_path, variables_mapping)
|
||||
self.assertTrue(result["success"])
|
||||
self.assertIn("token", result["output"])
|
||||
result = run_suite_path(testcase_file_path, variables_mapping)
|
||||
self.assertTrue(result.success)
|
||||
self.assertIn("token", result.output)
|
||||
|
||||
def test_run_testcase_with_empty_header(self):
|
||||
testcase_file_path = os.path.join(
|
||||
|
||||
Reference in New Issue
Block a user