From 481b19c3e6aa56e05856bd1990e716339218cc53 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 4 Jul 2022 22:53:25 +0800 Subject: [PATCH] fix: check testcase format --- hrp/runner_test.go | 2 +- hrp/testcase.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hrp/runner_test.go b/hrp/runner_test.go index 9c169bc1..d5d7c30b 100644 --- a/hrp/runner_test.go +++ b/hrp/runner_test.go @@ -221,7 +221,7 @@ func TestLoadTestCases(t *testing.T) { if !assert.Nil(t, err) { t.Fatal() } - if !assert.Equal(t, len(testCases), 4) { + if !assert.Equal(t, 4, len(testCases)) { t.Fatal() } diff --git a/hrp/testcase.go b/hrp/testcase.go index a9a55d5f..55e40dd4 100644 --- a/hrp/testcase.go +++ b/hrp/testcase.go @@ -60,14 +60,17 @@ func (path *TestCasePath) ToTestCase() (*TestCase, error) { if err != nil { return nil, err } - if tc.Config == nil { - tc.Config = &TConfig{Name: "testcase name"} + if tc.TestSteps == nil { + 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"} + } tc.Config.Path = casePath testCase := &TestCase{