diff --git a/hrp/boomer.go b/hrp/boomer.go index c8cd9349..df8e423b 100644 --- a/hrp/boomer.go +++ b/hrp/boomer.go @@ -2,8 +2,6 @@ package hrp import ( "fmt" - "github.com/httprunner/httprunner/v4/hrp/internal/builtin" - "golang.org/x/net/context" "io/ioutil" "os" "path/filepath" @@ -13,9 +11,11 @@ import ( "github.com/httprunner/funplugin" "github.com/httprunner/httprunner/v4/hrp/internal/boomer" + "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/json" "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/rs/zerolog/log" + "golang.org/x/net/context" ) func NewStandaloneBoomer(spawnCount int64, spawnRate float64) *HRPBoomer { @@ -100,6 +100,15 @@ func (b *HRPBoomer) Run(testcases ...ITestCase) { // report execution timing event defer sdk.SendEvent(event.StartTiming("execution")) + // quit all plugins + defer func() { + if len(pluginMap) > 0 { + for _, plugin := range pluginMap { + plugin.Quit() + } + } + }() + taskSlice := b.ConvertTestCasesToBoomerTasks(testcases...) b.Boomer.Run(taskSlice...) @@ -113,15 +122,6 @@ func (b *HRPBoomer) ConvertTestCasesToBoomerTasks(testcases ...ITestCase) (taskS os.Exit(1) } - // quit all plugins - defer func() { - if len(pluginMap) > 0 { - for _, plugin := range pluginMap { - plugin.Quit() - } - } - }() - for _, testcase := range testCases { rendezvousList := initRendezvous(testcase, int64(b.GetSpawnCount())) task := b.convertBoomerTask(testcase, rendezvousList) diff --git a/hrp/runner.go b/hrp/runner.go index e6662613..b9192e09 100644 --- a/hrp/runner.go +++ b/hrp/runner.go @@ -285,15 +285,17 @@ func (r *HRPRunner) newCaseRunner(testcase *TestCase) (*testCaseRunner, error) { // load plugin info to testcase config if plugin != nil { pluginPath, _ := locatePlugin(testcase.Config.Path) - pluginContent, err := builtin.ReadFile(pluginPath) - if err != nil { - return nil, err - } - tp := strings.Split(plugin.Path(), ".") - runner.parsedConfig.PluginSetting = &PluginConfig{ - Path: pluginPath, - Content: pluginContent, - Type: tp[len(tp)-1], + if runner.parsedConfig.PluginSetting == nil { + pluginContent, err := builtin.ReadFile(pluginPath) + if err != nil { + return nil, err + } + tp := strings.Split(plugin.Path(), ".") + runner.parsedConfig.PluginSetting = &PluginConfig{ + Path: pluginPath, + Content: pluginContent, + Type: tp[len(tp)-1], + } } } diff --git a/hrp/testcase.go b/hrp/testcase.go index ffedd829..e1cd4533 100644 --- a/hrp/testcase.go +++ b/hrp/testcase.go @@ -104,10 +104,6 @@ func (tc *TCase) ToTestCase(casePath string) (*TestCase, error) { return nil, errors.New("invalid testcase format, missing teststeps!") } - err := tc.MakeCompat() - if err != nil { - return nil, err - } if tc.Config == nil { tc.Config = &TConfig{Name: "please input testcase name"} } @@ -121,6 +117,11 @@ func (tc *TCase) toTestCase() (*TestCase, error) { Config: tc.Config, } + err := tc.MakeCompat() + if err != nil { + return nil, err + } + // locate project root dir by plugin path projectRootDir, err := GetProjectRootDirPath(tc.Config.Path) if err != nil {