feat: dump TestCase to json/yaml file

This commit is contained in:
debugtalk
2022-09-01 23:27:14 +08:00
parent e338590010
commit 47ac7dba0b
2 changed files with 26 additions and 2 deletions

View File

@@ -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