Skip to content

Commit

Permalink
+ [feat] add parse tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ysicing committed Oct 17, 2024
1 parent 439f8f8 commit a41cf8b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions cmd/test/debug/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

import (
"flag"
"fmt"

"github.com/davecgh/go-spew/spew"
commConsts "github.com/easysoft/zentaoatf/internal/pkg/consts"
execHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/exec"
serverDomain "github.com/easysoft/zentaoatf/internal/server/modules/v1/domain"
)

var resultfile string

func init() {
flag.StringVar(&resultfile, "resultfile", "", "result file")
}

func main() {
flag.Parse()
req := serverDomain.TestSet{
TestTool: commConsts.PyTest,
ResultDir: resultfile,
}
testSuites := execHelper.RetrieveUnitResult(req, 0)
spew.Dump(testSuites)
cases, _, _ := execHelper.ParserUnitTestResult(testSuites)
spew.Dump(cases)
failedCaseLines := make([]string, 0)
failedCaseLinesDesc := make([]string, 0)
Fail, Pass, Total := 0, 0, 0
for idx, cs := range cases {
if cs.Failure != nil {
Fail++

className := cases[idx].TestSuite

line := fmt.Sprintf("[%s] %s", className, cs.Title)
failedCaseLines = append(failedCaseLines, line)
failedCaseLinesDesc = append(failedCaseLinesDesc, line)
failDesc := fmt.Sprintf(" %s - %s", cs.Failure.Type, cs.Failure.Desc)
failedCaseLinesDesc = append(failedCaseLinesDesc, failDesc)
} else {
Pass++
}

Total++
}
fmt.Printf("Pass: %d, Fail: %d, Total: %d\n", Pass, Fail, Total)
}

0 comments on commit a41cf8b

Please sign in to comment.