From 1a3a714929b597aa9a92224ecbad3e12ab4a1ff9 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Sun, 10 Oct 2021 12:21:24 +0800 Subject: [PATCH] refactor: rename API --- README.md | 5 ++--- boomer.go | 2 +- convert_test.go | 2 +- examples/demo_test.go | 2 +- examples/extract_test.go | 4 ++-- examples/function_test.go | 2 +- examples/request_test.go | 2 +- examples/validate_test.go | 2 +- examples/variables_test.go | 8 ++++---- runner.go | 2 +- runner_test.go | 2 +- 11 files changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 452722d2..084f4dfe 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ HttpBoomer is a golang implementation of [HttpRunner]. Ideally, HttpBoomer will - [x] Supports `variables`/`extract`/`validate`/`hooks` mechanisms to create extremely complex test scenarios. - [ ] Built-in integration of rich functions, and you can also use [`go plugin`][plugin] to create and call custom functions. - [x] Inherit all powerful features of [`Boomer`][Boomer] and [`locust`][locust], you can run `load test` without extra work. -- [ ] Use it as a `CLI tool` or as a `library` are both supported. +- [x] Use it as a `CLI tool` or as a `library` are both supported. ## Quick Start @@ -35,7 +35,6 @@ $ go get -u github.com/httprunner/httpboomer This is an example of HttpBoomer testcase. You can find more in the [`examples`][examples] directory. ```go - import ( "testing" @@ -86,7 +85,7 @@ func TestCaseDemo(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/boomer.go b/boomer.go index 5c054602..5680137c 100644 --- a/boomer.go +++ b/boomer.go @@ -6,7 +6,7 @@ import ( "github.com/myzhan/boomer" ) -func Run(testcases ...ITestCase) { +func Boom(testcases ...ITestCase) { NewBoomer().Run(testcases...) } diff --git a/convert_test.go b/convert_test.go index 381029f0..b4737f91 100644 --- a/convert_test.go +++ b/convert_test.go @@ -122,7 +122,7 @@ func TestLoadJSONAndRun(t *testing.T) { if !assert.NoError(t, err) { t.Fail() } - err = Test(t, testcase) + err = Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/demo_test.go b/examples/demo_test.go index f421b3bd..8817a24d 100644 --- a/examples/demo_test.go +++ b/examples/demo_test.go @@ -50,7 +50,7 @@ func TestCaseDemo(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/extract_test.go b/examples/extract_test.go index 5a7c05e0..f85368a2 100644 --- a/examples/extract_test.go +++ b/examples/extract_test.go @@ -37,7 +37,7 @@ func TestCaseExtractStepSingle(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } @@ -82,7 +82,7 @@ func TestCaseExtractStepAssociation(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/function_test.go b/examples/function_test.go index e9398240..098847fd 100644 --- a/examples/function_test.go +++ b/examples/function_test.go @@ -40,7 +40,7 @@ func TestCaseCallFunction(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/request_test.go b/examples/request_test.go index 3180244b..4a99f98f 100644 --- a/examples/request_test.go +++ b/examples/request_test.go @@ -57,7 +57,7 @@ func TestCaseBasicRequest(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/validate_test.go b/examples/validate_test.go index ab6bbf96..daecd4fb 100644 --- a/examples/validate_test.go +++ b/examples/validate_test.go @@ -51,7 +51,7 @@ func TestCaseValidateStep(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/variables_test.go b/examples/variables_test.go index 5ce4262c..c297daa2 100644 --- a/examples/variables_test.go +++ b/examples/variables_test.go @@ -33,7 +33,7 @@ func TestCaseConfigVariables(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } @@ -66,7 +66,7 @@ func TestCaseStepVariables(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } @@ -104,7 +104,7 @@ func TestCaseOverrideConfigVariables(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } @@ -151,7 +151,7 @@ func TestCaseParseVariables(t *testing.T) { }, } - err := httpboomer.Test(t, testcase) + err := httpboomer.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/runner.go b/runner.go index 43a99005..d5151502 100644 --- a/runner.go +++ b/runner.go @@ -8,7 +8,7 @@ import ( "github.com/imroc/req" ) -func Test(t *testing.T, testcases ...ITestCase) error { +func Run(t *testing.T, testcases ...ITestCase) error { return NewRunner().WithTestingT(t).SetDebug(true).Run(testcases...) } diff --git a/runner_test.go b/runner_test.go index 7b366c43..b770a964 100644 --- a/runner_test.go +++ b/runner_test.go @@ -32,7 +32,7 @@ func TestHttpRunner(t *testing.T) { } testcase3 := &TestCasePath{demoTestCaseJSONPath} - err := Test(t, testcase1, testcase2, testcase3) + err := Run(t, testcase1, testcase2, testcase3) if err != nil { t.Fatalf("run testcase error: %v", err) }