提交 e3aa9fe3 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

support cyrpress test framework

上级 8385cfd6
......@@ -405,3 +405,41 @@ type RobotStatus struct {
StartTime string `xml:"starttime,attr"`
EndTime string `xml:"endtime,attr"`
}
// cypress
var CypressResults = "results"
type CypressTestsuites struct {
XMLName xml.Name `xml:"testsuites"`
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Time string `xml:"time,attr"`
Tests string `xml:"tests,attr"`
Failures string `xml:"failures,attr"`
Testsuites []CypressTestsuite `xml:"testsuite"`
}
type CypressTestsuite struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Timestamp string `xml:"timestamp,attr"`
Tests string `xml:"tests,attr"`
File string `xml:"file,attr"`
Time float64 `xml:"time,attr"`
Failures string `xml:"failures,attr"`
Testcases []CypressTestcase `xml:"testcase"`
}
type CypressTestcase struct {
Text string `xml:",chardata"`
Name string `xml:"name,attr"`
Time float64 `xml:"time,attr"`
Classname string `xml:"classname,attr"`
Failures []CypressFailure `xml:"failure"`
}
type CypressFailure struct {
Text string `xml:",chardata"`
Message string `xml:"message,attr"`
Type string `xml:"type,attr"`
}
......@@ -22,7 +22,7 @@ func RetrieveUnitResult() (suites []model.UnitTestSuite, resultDir string) {
resultDir = fmt.Sprintf("target%ssurefire-reports%s", constant.PthSep, constant.PthSep)
} else if vari.UnitTestType == constant.UnitTestTypeTestNG && vari.UnitTestTool == constant.UnitTestToolMvn {
resultDir = fmt.Sprintf("target%ssurefire-reports%sjunitreports", constant.PthSep, constant.PthSep)
} else if vari.UnitTestType == constant.UnitTestTypeRobot {
} else if vari.UnitTestType == constant.UnitTestTypeRobot || vari.UnitTestType == constant.UnitTestTypeCypress {
resultDir = vari.UnitTestResults
} else {
resultDir = vari.UnitTestResult
......@@ -103,6 +103,12 @@ func RetrieveUnitResult() (suites []model.UnitTestSuite, resultDir string) {
if err == nil {
testSuite = ConvertRobotResult(robotResult)
}
} else if vari.UnitTestType == "cypress" {
cyResult := model.CypressTestsuites{}
err = xml.Unmarshal([]byte(content), &cyResult)
if err == nil {
testSuite = ConvertCyResult(cyResult)
}
}
if err == nil {
......@@ -373,3 +379,43 @@ func RetrieveRobotTests(suite model.RobotSuite, tests *[]model.RobotTest) {
*tests = append(*tests, test)
}
}
func ConvertCyResult(result model.CypressTestsuites) model.UnitTestSuite {
testSuite := model.UnitTestSuite{}
for _, suite := range result.Testsuites {
if suite.Name == "Root Suite" {
continue
}
templ := "20060102 15:04:05.000"
duration := suite.Time
startTime, _ := time.ParseInLocation(templ, suite.Timestamp, time.Local)
//endTime := time.Unix(startTime.Unix() + int64(duration), 0)
testSuite.Duration = int64(duration)
testSuite.Time = float32(startTime.Unix())
for _, cs := range suite.Testcases {
caseResult := model.UnitResult{}
caseResult.TestSuite = suite.Name
caseResult.Title = cs.Name
caseResult.Duration = float32(cs.Time)
if len(cs.Failures) > 0 {
caseResult.Status = "fail"
fail := model.Failure{}
fail.Type = cs.Failures[0].Type
fail.Desc = cs.Failures[0].Message
caseResult.Failure = &fail
} else {
caseResult.Status = "pass"
}
testSuite.TestCases = append(testSuite.TestCases, caseResult)
}
}
return testSuite
}
......@@ -41,11 +41,12 @@ var (
RequestTypePathInfo = "PATH_INFO"
AutoTestTypes = []string{"selenium", "appium"}
UnitTestTypeJunit = "junit"
UnitTestTypeTestNG = "testng"
UnitTestTypeRobot = "robot"
UnitTestTypes = []string{UnitTestTypeJunit, UnitTestTypeTestNG, UnitTestTypeRobot,
AutoTestTypes = []string{"selenium", "appium"}
UnitTestTypeJunit = "junit"
UnitTestTypeTestNG = "testng"
UnitTestTypeRobot = "robot"
UnitTestTypeCypress = "cypress"
UnitTestTypes = []string{UnitTestTypeJunit, UnitTestTypeTestNG, UnitTestTypeRobot, UnitTestTypeCypress,
"phpunit", "pytest", "jest", "cppunit", "gtest", "qtest"}
UnitTestToolMvn = "mvn"
UnitTestToolRobot = "robot"
......
......@@ -74,8 +74,8 @@ func main() {
flagSet.BoolVar(&noNeedConfirm, "y", false, "")
flagSet.BoolVar(&vari.Verbose, "verbose", false, "")
flagSet.IntVar(&vari.Port, "P", 8848, "")
flagSet.IntVar(&vari.Port, "port", 8848, "")
flagSet.IntVar(&vari.Port, "P", 0, "")
flagSet.IntVar(&vari.Port, "port", 0, "")
flagSet.StringVar(&vari.Platform, "M", string(serverConst.Vm), "")
var placeholder string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册