diff --git a/runner.go b/runner.go index 2362ab3a..6a21ca34 100644 --- a/runner.go +++ b/runner.go @@ -36,9 +36,18 @@ func (r *Runner) runCase(testcase *TestCase) error { config := &testcase.Config log.Printf("Start to run testcase: %v", config.Name) for _, step := range testcase.TestSteps { - tStep := parseStep(step, config) - if err := r.runStep(tStep); err != nil { - return err + if tc, ok := step.(*testcaseWithOptionalArgs); ok { + // run referenced testcase + log.Printf("run referenced testcase: %v", tc.step.Name) + if err := r.runCase(tc.step.TestCase); err != nil { + return err + } + } else { + // run request + tStep := parseStep(step, config) + if err := r.runStep(tStep); err != nil { + return err + } } } return nil diff --git a/runner_test.go b/runner_test.go index c21c5321..842a8bbe 100644 --- a/runner_test.go +++ b/runner_test.go @@ -21,7 +21,7 @@ func TestHttpRunner(t *testing.T) { Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.\"user-agent\"", "python-requests", "check User-Agent"), - Step("TestCase3").CallRefCase(&TestCase{}), + Step("TestCase3").CallRefCase(&TestCase{Config: TConfig{Name: "TestCase3"}}), }, } testcase2 := &TestCase{