mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 14:32:31 +08:00
feat: add run subcommand
This commit is contained in:
13
cmd/root.go
13
cmd/root.go
@@ -12,14 +12,13 @@ import (
|
|||||||
// rootCmd represents the base command when called without any subcommands
|
// rootCmd represents the base command when called without any subcommands
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "httpboomer",
|
Use: "httpboomer",
|
||||||
Short: "httpboomer = httprunner + boomer",
|
Short: "One-stop solution for HTTP(S) testing.",
|
||||||
Long: `HttpBoomer is a golang implementation of HttpRunner.
|
Long: `HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
|
||||||
Ideally, HttpBoomer will be fully compatible with HttpRunner, including testcase format and usage.
|
|
||||||
What's more, HttpBoomer will integrate Boomer natively to be a better load generator for locust.`,
|
License: Apache-2.0
|
||||||
|
Github: https://github.com/httprunner/httpboomer
|
||||||
|
Copyright 2021 debugtalk`,
|
||||||
Version: httpboomer.VERSION,
|
Version: httpboomer.VERSION,
|
||||||
// Uncomment the following line if your bare application
|
|
||||||
// has an action associated with it:
|
|
||||||
// Run: func(cmd *cobra.Command, args []string) {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
|
|||||||
35
cmd/run.go
Normal file
35
cmd/run.go
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/httprunner/httpboomer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// runCmd represents the run command
|
||||||
|
var runCmd = &cobra.Command{
|
||||||
|
Use: "run path...",
|
||||||
|
Short: "run API test",
|
||||||
|
Long: `run yaml/json testcase files`,
|
||||||
|
Example: ` $ httpboomer run demo.json # run specified json testcase file
|
||||||
|
$ httpboomer run demo.yaml # run specified yaml testcase file
|
||||||
|
$ httpboomer run examples/ # run testcases in specified folder`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
|
// f, _ := cmd.Flags().GetBool("gen-html-report")
|
||||||
|
// fmt.Println(f)
|
||||||
|
|
||||||
|
var paths []httpboomer.ITestCase
|
||||||
|
for _, arg := range args {
|
||||||
|
paths = append(paths, &httpboomer.TestCasePath{Path: arg})
|
||||||
|
}
|
||||||
|
return httpboomer.Run(&testing.T{}, paths...)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(runCmd)
|
||||||
|
runCmd.Flags().BoolP("gen-html-report", "r", false, "Generate HTML report")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user