Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #75 from xucong053/main
Browse files Browse the repository at this point in the history
feat: generate html reports for API testing #74
  • Loading branch information
debugtalk authored Feb 8, 2022
2 parents 787ab65 + 6aeeab2 commit 8f99ec7
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 42 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
fail-fast: true
matrix:
go-version:
- 1.13.x
- 1.14.x
- 1.15.x
- 1.16.x
- 1.17.x
os: [ubuntu-latest, macos-latest, windows-latest]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See [CHANGELOG].
- [x] Data driven with `parameterize` mechanism, supporting sequential/random/unique strategies to select data.
- [ ] Built-in 100+ commonly used functions for ease, including md5sum, max/min, sleep, gen_random_string etc.
- [x] Create and call custom functions with `plugin` mechanism, support [hashicorp plugin] and [go plugin].
- [ ] Generate html reports with rich test results.
- [x] Generate html reports with rich test results.
- [x] Using it as a `CLI tool` or a `library` are both supported.

### Load Testing
Expand Down
6 changes: 5 additions & 1 deletion cli/hrp/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ var runCmd = &cobra.Command{
SetDebug(!silentFlag).
SetFailfast(!continueOnFailure).
SetSaveTests(saveTests)
if genHTMLReport {
runner.GenHTMLReport()
}
if proxyUrl != "" {
runner.SetProxyUrl(proxyUrl)
}
Expand All @@ -44,6 +47,7 @@ var (
silentFlag bool
proxyUrl string
saveTests bool
genHTMLReport bool
)

func init() {
Expand All @@ -52,5 +56,5 @@ func init() {
runCmd.Flags().BoolVarP(&silentFlag, "silent", "s", false, "disable logging request & response details")
runCmd.Flags().StringVarP(&proxyUrl, "proxy-url", "p", "", "set proxy url")
runCmd.Flags().BoolVar(&saveTests, "save-tests", false, "save tests summary")
// runCmd.Flags().BoolP("gen-html-report", "r", false, "Generate HTML report")
runCmd.Flags().BoolVarP(&genHTMLReport, "gen-html-report", "r", false, "generate html report")
}
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Release History

## v0.6.0 (2022-01-27)
## v0.6.0 (2022-02-08)

- feat: implement `rendezvous` mechanism for data driven
- feat: upload release artifacts to aliyun oss
- feat: dump tests summary for execution results
- feat: generate html report for API testing
- change: remove sentry sdk

## v0.5.3 (2022-01-25)
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/hrp.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ Copyright 2021 debugtalk
* [hrp run](hrp_run.md) - run API test
* [hrp startproject](hrp_startproject.md) - create a scaffold project

###### Auto generated by spf13/cobra on 27-Jan-2022
###### Auto generated by spf13/cobra on 8-Feb-2022
2 changes: 1 addition & 1 deletion docs/cmd/hrp_boom.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ hrp boom [flags]

* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.

###### Auto generated by spf13/cobra on 27-Jan-2022
###### Auto generated by spf13/cobra on 8-Feb-2022
2 changes: 1 addition & 1 deletion docs/cmd/hrp_har2case.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ hrp har2case $har_path... [flags]

* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.

###### Auto generated by spf13/cobra on 27-Jan-2022
###### Auto generated by spf13/cobra on 8-Feb-2022
3 changes: 2 additions & 1 deletion docs/cmd/hrp_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ hrp run $path... [flags]

```
--continue-on-failure continue running next step when failure occurs
-r, --gen-html-report generate html report
-h, --help help for run
-p, --proxy-url string set proxy url
--save-tests save tests summary
Expand All @@ -32,4 +33,4 @@ hrp run $path... [flags]

* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.

###### Auto generated by spf13/cobra on 27-Jan-2022
###### Auto generated by spf13/cobra on 8-Feb-2022
2 changes: 1 addition & 1 deletion docs/cmd/hrp_startproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ hrp startproject $project_name [flags]

* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.

###### Auto generated by spf13/cobra on 27-Jan-2022
###### Auto generated by spf13/cobra on 8-Feb-2022
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/httprunner/hrp

go 1.13
go 1.16

require (
github.com/denisbrodbeck/machineid v1.0.1
Expand Down
13 changes: 13 additions & 0 deletions internal/builtin/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,16 @@ func Dump2YAML(data interface{}, path string) error {
}
return nil
}

func FormatResponse(raw interface{}) interface{} {
formattedResponse := make(map[string]interface{})
for key, value := range raw.(map[string]interface{}) {
// convert value to json
if key == "body" {
b, _ := json.MarshalIndent(&value, "", " ")
value = string(b)
}
formattedResponse[key] = value
}
return formattedResponse
}
Loading

0 comments on commit 8f99ec7

Please sign in to comment.