mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 17:27:36 +08:00
add HttpRunner class as interface
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
from httprunner import exception, runner, testcase, utils
|
||||
from httprunner.cli import run_suite_path
|
||||
from httprunner import HttpRunner, exception, runner, testcase, utils
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
|
||||
@@ -78,11 +77,11 @@ class TestRunner(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
result = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
self.assertTrue(result.success)
|
||||
|
||||
def test_run_testsets_hardcode(self):
|
||||
result = run_suite_path(self.testcase_file_path_list)
|
||||
result = HttpRunner(self.testcase_file_path_list).run()
|
||||
self.assertTrue(result.success)
|
||||
self.assertEqual(result.stat.total, 6)
|
||||
self.assertEqual(result.stat.successes, 6)
|
||||
@@ -90,37 +89,37 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_run_testset_template_variables(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
result = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
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 = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
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 = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
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 = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
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 = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
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 = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
self.assertTrue(result.success)
|
||||
self.assertIn("token", result.output)
|
||||
|
||||
@@ -130,7 +129,7 @@ class TestRunner(ApiServerUnittest):
|
||||
variables_mapping = {
|
||||
"app_version": '2.9.7'
|
||||
}
|
||||
result = run_suite_path(testcase_file_path, variables_mapping)
|
||||
result = HttpRunner(testcase_file_path).run(variables_mapping)
|
||||
self.assertTrue(result.success)
|
||||
self.assertIn("token", result.output)
|
||||
|
||||
@@ -162,7 +161,7 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_run_testset_with_parameters(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_parameters.yml')
|
||||
result = run_suite_path(testcase_file_path)
|
||||
result = HttpRunner(testcase_file_path).run()
|
||||
self.assertTrue(result.success)
|
||||
self.assertIn("token", result.output)
|
||||
self.assertEqual(result.stat.total, 6)
|
||||
|
||||
Reference in New Issue
Block a user