mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 06:23:52 +08:00
feat: dump TestCase to json/yaml file
This commit is contained in:
@@ -7,11 +7,11 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// ITestCase represents interface for testcases,
|
||||
@@ -51,6 +51,24 @@ func (tc *TestCase) ToTCase() *TCase {
|
||||
return tCase
|
||||
}
|
||||
|
||||
func (tc *TestCase) Dump2JSON(targetPath string) error {
|
||||
tCase := tc.ToTCase()
|
||||
err := builtin.Dump2JSON(tCase, targetPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "dump testcase to json failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *TestCase) Dump2YAML(targetPath string) error {
|
||||
tCase := tc.ToTCase()
|
||||
err := builtin.Dump2YAML(tCase, targetPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "dump testcase to yaml failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TestCasePath implements ITestCase interface.
|
||||
type TestCasePath string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user