Skip to content

Commit

Permalink
Merge pull request #70 from programmfabrik/output_total_runtime
Browse files Browse the repository at this point in the history
added output of total runtime after all tests are done
  • Loading branch information
martinrode authored Dec 2, 2021
2 parents 1e95f42 + 5da3c1a commit 9b31022
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"time"

"github.com/programmfabrik/apitest/pkg/lib/datastore"
"github.com/programmfabrik/apitest/pkg/lib/report"
Expand Down Expand Up @@ -132,6 +133,9 @@ func setup(ccmd *cobra.Command, args []string) {

func runApiTests(cmd *cobra.Command, args []string) {

// timestamp: start of all tests
start := time.Now()

// Check if paths are valid
for _, rootDirectory := range rootDirectorys {
if _, err := os.Stat(rootDirectory); rootDirectory != "." && os.IsNotExist(err) {
Expand Down Expand Up @@ -216,6 +220,15 @@ func runApiTests(cmd *cobra.Command, args []string) {
rep.WriteToFile(reportFile, reportFormat)
}

// timestamp: end of all tests
end := time.Now()

time_format := "2006-01-02 15:04:05"
format_start := start.Format(time_format)
format_end := end.Format(time_format)
format_runtime := time.Since(start).String()
logrus.Infof("All done in %s. Start: %s. End: %s.", format_runtime, format_start, format_end)

if rep.DidFail() {
os.Exit(1)
}
Expand Down

0 comments on commit 9b31022

Please sign in to comment.