MCPcopy
hub / github.com/httprunner/httprunner / TestCaseConfigVariables

Function TestCaseConfigVariables

hrp/tests/variables_test.go:9–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestCaseConfigVariables(t *testing.T) {
10 testcase := &hrp.TestCase{
11 Config: hrp.NewConfig("run request with variables").
12 SetBaseURL("https://postman-echo.com").
13 WithVariables(map[string]interface{}{
14 "var1": "bar1",
15 "agent": "HttpRunnerPlus",
16 "expectedStatusCode": 200,
17 }).SetVerifySSL(false),
18 TestSteps: []hrp.IStep{
19 hrp.NewStep("get with params").
20 GET("/get").
21 WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
22 WithHeaders(map[string]string{"User-Agent": "$agent"}).
23 Validate().
24 AssertEqual("status_code", "$expectedStatusCode", "check status code").
25 AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
26 AssertEqual("body.args.foo1", "bar1", "check args foo1").
27 AssertEqual("body.args.foo2", "bar2", "check args foo2").
28 AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
29 },
30 }
31
32 err := hrp.NewRunner(t).Run(testcase)
33 if err != nil {
34 t.Fatalf("run testcase error: %v", err)
35 }
36}
37
38func TestCaseStepVariables(t *testing.T) {
39 testcase := &hrp.TestCase{

Callers

nothing calls this directly

Calls 12

NewConfigFunction · 0.92
NewStepFunction · 0.92
NewRunnerFunction · 0.92
SetVerifySSLMethod · 0.80
SetBaseURLMethod · 0.80
AssertEqualMethod · 0.80
GETMethod · 0.80
RunMethod · 0.65
WithVariablesMethod · 0.45
ValidateMethod · 0.45
WithHeadersMethod · 0.45
WithParamsMethod · 0.45

Tested by

no test coverage detected