mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 20:27:37 +08:00
locusts support weight feature
This commit is contained in:
34
tests/data/demo_locust.yml
Normal file
34
tests/data/demo_locust.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
- config:
|
||||
name: basic test with httpbin
|
||||
request:
|
||||
base_url: https://httpbin.org/
|
||||
|
||||
- test:
|
||||
name: index
|
||||
weight: 5
|
||||
request:
|
||||
url: /
|
||||
method: GET
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- contains: [content, "HTTP Request & Response Service"]
|
||||
|
||||
- test:
|
||||
name: headers
|
||||
weight: 3
|
||||
request:
|
||||
url: /headers
|
||||
method: GET
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- eq: [content.headers.Host, "httpbin.org"]
|
||||
|
||||
- test:
|
||||
name: user-agent
|
||||
weight: 2
|
||||
request:
|
||||
url: /user-agent
|
||||
method: GET
|
||||
validate:
|
||||
- eq: ["status_code", 200]
|
||||
- startswith: [content.user-agent, "python-requests"]
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from httprunner import HttpRunner, LocustRunner, api, loader, parser
|
||||
from httprunner import HttpRunner, api, loader, parser
|
||||
from locust import HttpLocust
|
||||
from tests.api_server import HTTPBIN_SERVER
|
||||
from tests.base import ApiServerUnittest
|
||||
@@ -375,15 +375,3 @@ class TestHttpRunner(ApiServerUnittest):
|
||||
os.getcwd(), 'tests/httpbin/basic.yml')
|
||||
runner = HttpRunner().run(testcase_file_path)
|
||||
self.assertTrue(runner.summary["success"])
|
||||
|
||||
|
||||
class TestLocustRunner(ApiServerUnittest):
|
||||
|
||||
def setUp(self):
|
||||
WebPageUser = type('WebPageUser', (HttpLocust,), {})
|
||||
self.locust_client = WebPageUser.client
|
||||
|
||||
def test_LocustRunner(self):
|
||||
testcase_file = os.path.join(os.getcwd(), 'tests', 'httpbin', 'basic.yml')
|
||||
locust_runner = LocustRunner(self.locust_client)
|
||||
locust_runner.run(testcase_file)
|
||||
|
||||
@@ -553,3 +553,12 @@ class TestSuiteLoader(unittest.TestCase):
|
||||
self.assertIn("get_token", project_mapping["def-api"])
|
||||
self.assertIn("setup_and_reset", project_mapping["def-testcase"])
|
||||
self.assertEqual(project_mapping["env"]["PROJECT_KEY"], "ABCDEFGH")
|
||||
|
||||
def test_load_locust_tests(self):
|
||||
path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_locust.yml')
|
||||
locust_tests = loader.load_locust_tests(path)
|
||||
self.assertEqual(locust_tests["config"]["refs"]["env"]["UserName"], "debugtalk")
|
||||
self.assertEqual(len(locust_tests["tests"]), 10)
|
||||
self.assertEqual(locust_tests["tests"][0][0]["name"], "index")
|
||||
self.assertEqual(locust_tests["tests"][9][0]["name"], "user-agent")
|
||||
|
||||
Reference in New Issue
Block a user