diff --git a/boomer.go b/boomer.go index f9c603e6..e25a1b84 100644 --- a/boomer.go +++ b/boomer.go @@ -36,6 +36,10 @@ func (b *Boomer) Run(testcases ...ITestCase) { b.Boomer.Run(taskSlice...) } +func (b *Boomer) Quit() { + b.Boomer.Quit() +} + func (b *Boomer) convertBoomerTask(testcase *TestCase) *boomer.Task { runner := NewRunner(nil).SetDebug(b.debug) return &boomer.Task{ diff --git a/boomer_test.go b/boomer_test.go index 2197edd6..5d2e18a2 100644 --- a/boomer_test.go +++ b/boomer_test.go @@ -2,21 +2,33 @@ package hrp import ( "testing" + "time" ) -func TestHttpBoomer(t *testing.T) { - // testcase1 := &TestCase{ - // Config: TConfig{ - // Name: "TestCase1", - // Weight: 2, - // }, - // } - // testcase2 := &TestCase{ - // Config: TConfig{ - // Name: "TestCase2", - // Weight: 3, - // }, - // } +func TestBoomerStandaloneRun(t *testing.T) { + testcase1 := &TestCase{ + Config: TConfig{ + Name: "TestCase1", + BaseURL: "http://httpbin.org", + }, + TestSteps: []IStep{ + Step("headers"). + GET("/headers"). + Validate(). + AssertEqual("status_code", 200, "check status code"). + AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"), + Step("user-agent"). + GET("/user-agent"). + Validate(). + AssertEqual("status_code", 200, "check status code"). + AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"), + Step("TestCase3").CallRefCase(&TestCase{Config: TConfig{Name: "TestCase3"}}), + }, + } + testcase2 := &TestCasePath{demoTestCaseJSONPath} - // NewStandaloneBoomer(1, 1).Run(testcase1, testcase2) + b := NewStandaloneBoomer(2, 1) + go b.Run(testcase1, testcase2) + time.Sleep(5 * time.Second) + b.Quit() }