MCPcopy
hub / github.com/httprunner/httprunner / TestCaseStepVariables

Function TestCaseStepVariables

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

Source from the content-addressed store, hash-verified

36}
37
38func TestCaseStepVariables(t *testing.T) {
39 testcase := &hrp.TestCase{
40 Config: hrp.NewConfig("run request with variables").
41 SetBaseURL("https://postman-echo.com").
42 SetVerifySSL(false),
43 TestSteps: []hrp.IStep{
44 hrp.NewStep("get with params").
45 WithVariables(map[string]interface{}{
46 "var1": "bar1",
47 "agent": "HttpRunnerPlus",
48 "expectedStatusCode": 200,
49 }).
50 GET("/get").
51 WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
52 WithHeaders(map[string]string{"User-Agent": "$agent"}).
53 Validate().
54 AssertEqual("status_code", "$expectedStatusCode", "check status code").
55 AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
56 AssertEqual("body.args.foo1", "bar1", "check args foo1").
57 AssertEqual("body.args.foo2", "bar2", "check args foo2").
58 AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
59 },
60 }
61
62 err := hrp.NewRunner(t).Run(testcase)
63 if err != nil {
64 t.Fatalf("run testcase error: %v", err)
65 }
66}
67
68func TestCaseOverrideConfigVariables(t *testing.T) {
69 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
ValidateMethod · 0.45
WithHeadersMethod · 0.45
WithParamsMethod · 0.45
WithVariablesMethod · 0.45

Tested by

no test coverage detected