Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
3b8f7139
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
大约 1 年 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b8f7139
编写于
5月 31, 2023
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support set more than one id for unit testcase
上级
20019f3e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
32 deletion
+49
-32
internal/pkg/consts/enum.go
internal/pkg/consts/enum.go
+3
-2
internal/pkg/domain/testing.go
internal/pkg/domain/testing.go
+1
-0
internal/pkg/helper/config/config.go
internal/pkg/helper/config/config.go
+3
-1
internal/pkg/helper/exec/report-unit.go
internal/pkg/helper/exec/report-unit.go
+35
-21
internal/pkg/helper/exec/unit.go
internal/pkg/helper/exec/unit.go
+3
-3
internal/pkg/helper/unit/uint.go
internal/pkg/helper/unit/uint.go
+1
-1
internal/pkg/helper/zentao/result.go
internal/pkg/helper/zentao/result.go
+1
-2
test/restapi/api_result_test.go
test/restapi/api_result_test.go
+2
-2
未找到文件。
internal/pkg/consts/enum.go
浏览文件 @
3b8f7139
...
...
@@ -183,8 +183,9 @@ func (TestTool) Get(str string) TestTool {
type
BuildTool
string
const
(
Maven
BuildTool
=
"maven"
Mocha
BuildTool
=
"mocha"
Maven
BuildTool
=
"maven"
MavenShort
BuildTool
=
"mvn"
Mocha
BuildTool
=
"mocha"
)
func
(
e
BuildTool
)
String
()
string
{
...
...
internal/pkg/domain/testing.go
浏览文件 @
3b8f7139
...
...
@@ -248,6 +248,7 @@ type UnitResult struct {
Id
int
`json:"id"`
Cid
int
`json:"cid"`
Cids
string
`json:"-"`
Status
commConsts
.
ResultStatus
`json:"status"`
}
type
CaseSlice
[]
UnitResult
...
...
internal/pkg/helper/config/config.go
浏览文件 @
3b8f7139
...
...
@@ -38,7 +38,9 @@ func LoadByWorkspacePath(workspacePath string) (config commDomain.WorkspaceConf)
GetInterpreterConfig
(
&
config
)
return
}
pth
:=
filepath
.
Join
(
commConsts
.
ConfigPath
,
commConsts
.
ConfigFile
)
pth
:=
filepath
.
Join
(
workspacePath
,
commConsts
.
ConfigDir
,
commConsts
.
ConfigFile
)
return
LoadByConfigPath
(
pth
)
}
...
...
internal/pkg/helper/exec/report-unit.go
浏览文件 @
3b8f7139
...
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
"github.com/jinzhu/copier"
"io/ioutil"
"os"
"path"
...
...
@@ -181,6 +182,8 @@ func RetrieveUnitResult(testset serverDomain.TestSet, startTime int64) (
i118Utils
.
Sprintf
(
"must_provide_allure_report_dir"
)))
}
ExpandCaseForMultiIds
(
&
suites
)
}
else
{
failedCaseIdToThresholdMap
:=
map
[
string
]
string
{}
...
...
@@ -201,6 +204,26 @@ func RetrieveUnitResult(testset serverDomain.TestSet, startTime int64) (
return
}
func
ExpandCaseForMultiIds
(
suites
*
[]
commDomain
.
UnitTestSuite
)
{
for
idx1
,
suite
:=
range
*
suites
{
cases
:=
suite
.
Cases
(
*
suites
)[
idx1
]
.
Cases
=
[]
commDomain
.
UnitResult
{}
for
_
,
cs
:=
range
cases
{
ids
:=
strings
.
Split
(
cs
.
Cids
,
","
)
for
_
,
id
:=
range
ids
{
newCs
:=
commDomain
.
UnitResult
{}
copier
.
CopyWithOption
(
&
newCs
,
cs
,
copier
.
Option
{
DeepCopy
:
true
})
newCs
.
Cid
=
stringUtils
.
ParseInt
(
id
)
(
*
suites
)[
idx1
]
.
Cases
=
append
((
*
suites
)[
idx1
]
.
Cases
,
newCs
)
}
}
}
}
func
GetAllureSuites
(
resultDir
string
,
startTime
int64
)
(
suites
[]
commDomain
.
UnitTestSuite
)
{
files
,
err
:=
ioutil
.
ReadDir
(
resultDir
)
if
err
!=
nil
{
...
...
@@ -401,9 +424,7 @@ func ConvertAllureResult(cases []commDomain.AllureCase) (testSuites []commDomain
suiteMap
[
suiteName
]
=
&
suite
}
//suiteMap[suiteName].Name = "111"
caseId
:=
GetAllureCaseId
(
cs
)
caseIds
:=
GetAllureCaseId
(
cs
)
// passed, failed
var
status
commConsts
.
ResultStatus
...
...
@@ -413,8 +434,7 @@ func ConvertAllureResult(cases []commDomain.AllureCase) (testSuites []commDomain
status
=
commConsts
.
FAIL
}
caseResult
:=
commDomain
.
UnitResult
{
Id
:
caseId
,
Cid
:
caseId
,
Cids
:
caseIds
,
Title
:
cs
.
Name
,
TestSuite
:
suiteName
,
Duration
:
float32
(
cs
.
Stop
-
cs
.
Start
)
/
1000
,
...
...
@@ -466,10 +486,10 @@ func GetAllureCaseSuiteName(cs commDomain.AllureCase) (name string) {
return
}
func
GetAllureCaseId
(
cs
commDomain
.
AllureCase
)
(
id
int
)
{
func
GetAllureCaseId
(
cs
commDomain
.
AllureCase
)
(
id
s
string
)
{
// 1. from testCaseId
id
,
err
:=
strconv
.
Atoi
(
cs
.
TestCaseId
)
if
err
==
nil
&&
id
>
0
{
id
s
=
cs
.
TestCaseId
if
ids
!=
""
{
return
}
...
...
@@ -477,23 +497,18 @@ func GetAllureCaseId(cs commDomain.AllureCase) (id int) {
for
_
,
label
:=
range
cs
.
Labels
{
if
label
.
Name
==
"as_id"
{
if
label
.
Value
!=
""
{
cs
.
TestCaseId
=
label
.
Value
// 2
ids
=
label
.
Value
// 2
return
}
break
}
}
id
=
stringUtils
.
ParseInt
(
cs
.
TestCaseId
)
//
2. from the ids param in name like [cs-
1]
//
3. from the ids param in name like [
1]
regx
:=
regexp
.
MustCompile
(
`\[(.+)\]`
)
arr
:=
regx
.
FindAllStringSubmatch
(
cs
.
Name
,
-
1
)
if
len
(
arr
)
>
0
{
item
:=
arr
[
len
(
arr
)
-
1
]
idFromName
:=
stringUtils
.
ParseInt
(
item
[
1
])
if
idFromName
>
0
{
id
=
idFromName
}
ids
=
item
[
1
]
}
return
...
...
@@ -776,7 +791,7 @@ func isAllureReport(testTool commConsts.TestTool) (ret bool) {
}
func
getResultDirForDifferentTool
(
testset
*
serverDomain
.
TestSet
)
{
if
testset
.
TestTool
==
commConsts
.
JUnit
&&
testset
.
BuildTool
==
commConsts
.
Maven
{
if
(
testset
.
TestTool
==
commConsts
.
TestNG
||
testset
.
TestTool
==
commConsts
.
JUnit
)
&&
testset
.
BuildTool
==
commConsts
.
Maven
{
testset
.
ResultDir
=
filepath
.
Join
(
"target"
,
"surefire-reports"
)
testset
.
ZipDir
=
testset
.
ResultDir
...
...
@@ -827,7 +842,7 @@ func getZapReport() (ret string) {
}
func
getCaseIdFromName
(
cs
*
commDomain
.
UnitResult
,
defaultVal
int
)
{
if
cs
.
Cid
>
0
{
if
cs
.
Cid
s
!=
""
{
return
}
...
...
@@ -836,11 +851,10 @@ func getCaseIdFromName(cs *commDomain.UnitResult, defaultVal int) {
regx
:=
regexp
.
MustCompile
(
`^(\d+)\. (.+)`
)
arr
:=
regx
.
FindAllStringSubmatch
(
cs
.
Title
,
-
1
)
if
len
(
arr
)
>
0
{
cs
.
Cid
=
stringUtils
.
ParseInt
(
arr
[
0
][
1
])
cs
.
Cid
s
=
arr
[
0
][
1
]
cs
.
Title
=
arr
[
0
][
2
]
}
cs
.
Id
=
cs
.
Cid
if
cs
.
Id
<=
0
{
cs
.
Id
=
defaultVal
}
...
...
internal/pkg/helper/exec/unit.go
浏览文件 @
3b8f7139
...
...
@@ -81,12 +81,12 @@ func ExecUnit(ch chan int, req serverDomain.TestSet, wsMsg *websocket.Message) (
// submit result
if
req
.
SubmitResult
&&
(
report
.
FuncResult
!=
nil
||
report
.
UnitResult
!=
nil
)
{
config
Dir
:=
req
.
WorkspacePath
workspace
Dir
:=
req
.
WorkspacePath
if
commConsts
.
ExecFrom
==
commConsts
.
FromCmd
{
config
Dir
=
commConsts
.
ZtfDir
workspace
Dir
=
commConsts
.
ZtfDir
}
config
:=
configHelper
.
LoadByWorkspacePath
(
config
Dir
)
config
:=
configHelper
.
LoadByWorkspacePath
(
workspace
Dir
)
err
=
zentaoHelper
.
CommitResult
(
report
,
req
.
ProductId
,
req
.
TaskId
,
config
,
wsMsg
)
}
...
...
internal/pkg/helper/unit/uint.go
浏览文件 @
3b8f7139
...
...
@@ -11,7 +11,7 @@ func GetUnitTools(args []string, startIndex int) {
str
:=
args
[
startIndex
]
if
str
==
commConsts
.
Maven
.
String
()
{
if
str
==
commConsts
.
Maven
Short
.
String
()
{
commConsts
.
UnitBuildTool
=
commConsts
.
Maven
}
else
if
str
==
commConsts
.
Mocha
.
String
()
{
commConsts
.
UnitBuildTool
=
commConsts
.
Mocha
...
...
internal/pkg/helper/zentao/result.go
浏览文件 @
3b8f7139
...
...
@@ -3,8 +3,6 @@ package zentaoHelper
import
(
"encoding/json"
"fmt"
"os"
commConsts
"github.com/easysoft/zentaoatf/internal/pkg/consts"
commDomain
"github.com/easysoft/zentaoatf/internal/pkg/domain"
websocketHelper
"github.com/easysoft/zentaoatf/internal/pkg/helper/websocket"
...
...
@@ -13,6 +11,7 @@ import (
logUtils
"github.com/easysoft/zentaoatf/pkg/lib/log"
"github.com/fatih/color"
"github.com/kataras/iris/v12/websocket"
"os"
)
func
CommitResult
(
report
commDomain
.
ZtfReport
,
productId
,
taskId
int
,
config
commDomain
.
WorkspaceConf
,
...
...
test/restapi/api_result_test.go
浏览文件 @
3b8f7139
...
...
@@ -37,11 +37,11 @@ func (s *ResultApiSuite) TestResultSubmitApi(t provider.T) {
json
.
Unmarshal
([]
byte
(
reportJson
),
&
report
)
_
,
err
:=
httpHelper
.
Post
(
url
,
token
,
report
)
t
.
Require
()
.
Equal
(
err
,
nil
,
"
list testsuite
failed"
)
t
.
Require
()
.
Equal
(
err
,
nil
,
"
submit result
failed"
)
latestIdNew
:=
getCaseResult
(
CaseId
)[
"latestId"
]
.
(
int64
)
t
.
Require
()
.
Equal
(
latestIdNew
,
latestId
+
1
,
"
list testsuite
failed"
)
t
.
Require
()
.
Equal
(
latestIdNew
,
latestId
+
1
,
"
submit result
failed"
)
}
func
getCaseResult
(
caseId
int
)
(
result
map
[
string
]
interface
{})
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录