Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
4774500e
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
4774500e
编写于
8月 28, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
submit bug
上级
52279afc
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
126 addition
and
68 deletion
+126
-68
res/messages_en.json
res/messages_en.json
+12
-2
res/messages_zh.json
res/messages_zh.json
+12
-2
src/action/bug.go
src/action/bug.go
+25
-0
src/atf.go
src/atf.go
+10
-0
src/model/config.go
src/model/config.go
+0
-3
src/model/testing.go
src/model/testing.go
+3
-5
src/service/zentao/bug.go
src/service/zentao/bug.go
+19
-18
src/service/zentao/field.go
src/service/zentao/field.go
+1
-1
src/ui/page/pageReportBug.go
src/ui/page/pageReportBug.go
+2
-2
src/utils/config/config.go
src/utils/config/config.go
+4
-0
src/utils/const/const.go
src/utils/const/const.go
+35
-0
src/utils/log/print.go
src/utils/log/print.go
+3
-35
未找到文件。
res/messages_en.json
浏览文件 @
4774500e
...
...
@@ -11,6 +11,11 @@
"message"
:
"begin config, type 'exit' to quit"
,
"translation"
:
"begin to config"
},
{
"id"
:
"test_case"
,
"message"
:
"test case"
,
"translation"
:
"case"
},
{
"id"
:
"result"
,
"message"
:
"result"
,
...
...
@@ -21,6 +26,11 @@
"message"
:
"enter dir"
,
"translation"
:
"enter %s dir."
},
{
"id"
:
"enter_id"
,
"message"
:
"enter id"
,
"translation"
:
"enter %s id."
},
{
"id"
:
"dir_not_exist"
,
"message"
:
""
,
...
...
@@ -271,8 +281,8 @@
},
{
"id"
:
"success_to_report_bug"
,
"message"
:
"success to report a bug for case %s
-%s
"
,
"translation"
:
"success to report a bug for case %s
-%s
"
"message"
:
"success to report a bug for case %s"
,
"translation"
:
"success to report a bug for case %s"
},
{
"id"
:
"success_to_submit_result"
,
...
...
res/messages_zh.json
浏览文件 @
4774500e
...
...
@@ -11,6 +11,11 @@
"message"
:
"begin config"
,
"translation"
:
"开始配置, 输入'exit'退出"
},
{
"id"
:
"test_case"
,
"message"
:
"test case"
,
"translation"
:
"用例"
},
{
"id"
:
"result"
,
"message"
:
"result"
,
...
...
@@ -21,6 +26,11 @@
"message"
:
"enter dir"
,
"translation"
:
"输入%s目录"
},
{
"id"
:
"enter_id"
,
"message"
:
"enter id"
,
"translation"
:
"enter %s id."
},
{
"id"
:
"dir_not_exist"
,
"message"
:
""
,
...
...
@@ -263,8 +273,8 @@
},
{
"id"
:
"success_to_report_bug"
,
"message"
:
"success to report a bug for case %s
-%s
"
,
"translation"
:
"成功为用例%s
-%s
提交缺陷"
"message"
:
"success to report a bug for case %s"
,
"translation"
:
"成功为用例%s提交缺陷"
},
{
"id"
:
"success_to_submit_result"
,
...
...
src/action/bug.go
0 → 100644
浏览文件 @
4774500e
package
action
import
(
zentaoService
"github.com/easysoft/zentaoatf/src/service/zentao"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
)
func
CommitBug
(
files
[]
string
,
caseId
string
)
{
var
resultDir
string
if
len
(
files
)
>
0
{
resultDir
=
files
[
0
]
}
else
{
configUtils
.
ConfigForDir
(
&
resultDir
,
"result"
)
}
if
caseId
==
""
{
configUtils
.
ConfigForInt
(
&
caseId
,
"test_case"
)
}
resultDir
=
fileUtils
.
UpdateDir
(
resultDir
)
bug
,
stepIds
:=
zentaoService
.
GenBug
(
resultDir
,
caseId
)
zentaoService
.
CommitBug
(
bug
,
stepIds
)
}
src/atf.go
浏览文件 @
4774500e
...
...
@@ -20,6 +20,7 @@ func main() {
var
task
string
var
suite
string
var
result
string
var
caseId
string
flagSet
:=
flag
.
NewFlagSet
(
"atf"
,
flag
.
ContinueOnError
)
...
...
@@ -49,6 +50,9 @@ func main() {
flagSet
.
StringVar
(
&
keywords
,
"k"
,
""
,
""
)
flagSet
.
StringVar
(
&
keywords
,
"keywords"
,
""
,
""
)
flagSet
.
StringVar
(
&
caseId
,
"c"
,
""
,
""
)
flagSet
.
StringVar
(
&
caseId
,
"case"
,
""
,
""
)
switch
os
.
Args
[
1
]
{
case
"run"
:
files
,
idx
:=
commonUtils
.
GetFilesFromParams
(
os
.
Args
[
2
:
])
...
...
@@ -80,6 +84,12 @@ func main() {
action
.
CommitResult
(
files
)
}
case
"bug"
:
files
,
idx
:=
commonUtils
.
GetFilesFromParams
(
os
.
Args
[
2
:
])
if
err
:=
flagSet
.
Parse
(
os
.
Args
[
idx
+
1
:
]);
err
==
nil
{
action
.
CommitBug
(
files
,
caseId
)
}
case
"ls"
:
files
,
idx
:=
commonUtils
.
GetFilesFromParams
(
os
.
Args
[
2
:
])
if
err
:=
flagSet
.
Parse
(
os
.
Args
[
idx
+
1
:
]);
err
==
nil
{
...
...
src/model/config.go
浏览文件 @
4774500e
...
...
@@ -6,7 +6,4 @@ type Config struct {
Url
string
Account
string
Password
string
ProductId
int
ProjectId
int
}
src/model/testing.go
浏览文件 @
4774500e
...
...
@@ -110,11 +110,9 @@ type TestReport struct {
type
CaseLog
struct
{
Id
int
ProductId
int
TaskId
int
//ZentaoResultId int
Path
string
Status
string
Title
string
Path
string
Status
string
Title
string
Steps
[]
StepLog
}
...
...
src/service/zentao/bug.go
浏览文件 @
4774500e
...
...
@@ -6,6 +6,7 @@ import (
"github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/service/client"
testingService
"github.com/easysoft/zentaoatf/src/service/testing"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari"
...
...
@@ -14,14 +15,16 @@ import (
"strings"
)
func
GenBug
(
resultDir
string
)
(
model
.
Bug
,
string
)
{
//conf := configUtils.ReadCurrConfig()
productId
:=
0
// conf.ProductId
projectId
:=
0
// conf.ProjectId
func
GenBug
(
resultDir
string
,
caseIdStr
string
)
(
model
.
Bug
,
string
)
{
caseId
,
err
:=
strconv
.
Atoi
(
caseIdStr
)
if
err
!=
nil
{
return
model
.
Bug
{},
""
}
report
:=
testingService
.
GetTestTestReportForSubmit
(
resultDir
)
for
_
,
cs
:=
range
report
.
Cases
{
if
cs
.
Id
!=
vari
.
CurrC
aseId
{
if
cs
.
Id
!=
c
aseId
{
continue
}
...
...
@@ -32,11 +35,8 @@ func GenBug(resultDir string) (model.Bug, string) {
severity
:=
GetFirstNoEmptyVal
(
vari
.
ZentaoBugFileds
.
Severities
)
priority
:=
GetFirstNoEmptyVal
(
vari
.
ZentaoBugFileds
.
Priorities
)
product
:=
productId
project
:=
projectId
product
:=
cs
.
ProductId
caseId
:=
cs
.
Id
//Result := cs.ZentaoResultId
taskId
:=
cs
.
TaskId
uid
:=
uuid
.
NewV4
()
.
String
()
caseVersion
:=
"0"
...
...
@@ -55,9 +55,8 @@ func GenBug(resultDir string) (model.Bug, string) {
bug
:=
model
.
Bug
{
Title
:
title
,
Module
:
module
,
Type
:
typ
,
OpenedBuild
:
openedBuild
,
Severity
:
severity
,
Pri
:
priority
,
Product
:
strconv
.
Itoa
(
product
),
Project
:
strconv
.
Itoa
(
project
),
Case
:
strconv
.
Itoa
(
caseId
),
//Result: strconv.Itoa(Result),
Testtask
:
strconv
.
Itoa
(
taskId
),
Steps
:
strings
.
Join
(
steps
,
"<br/>"
),
Product
:
strconv
.
Itoa
(
product
),
Project
:
"0"
,
Case
:
strconv
.
Itoa
(
caseId
),
Testtask
:
"0"
,
Steps
:
strings
.
Join
(
steps
,
"<br/>"
),
Uid
:
uid
,
CaseVersion
:
caseVersion
,
OldTaskID
:
oldTaskID
,
}
return
bug
,
stepIds
...
...
@@ -67,17 +66,19 @@ func GenBug(resultDir string) (model.Bug, string) {
return
model
.
Bug
{},
""
}
func
SubmitBug
(
bug
model
.
Bug
,
idInTask
string
,
stepIds
string
)
bool
{
//conf := configUtils.ReadCurrConfig()
Login
(
"conf.Url"
,
"conf.Account"
,
"conf.Password"
)
func
CommitBug
(
bug
model
.
Bug
,
stepIds
string
)
bool
{
// TODO: open cui
conf
:=
configUtils
.
ReadCurrConfig
()
Login
(
conf
.
Url
,
conf
.
Account
,
conf
.
Password
)
productId
:=
bug
.
Product
projectId
:=
bug
.
Project
// bug-create-1-0-caseID=1,version=3,resultID=93,runID=0,stepIdList=9_12_
// bug-create-1-0-caseID=1,version=3,resultID=84,runID=6,stepIdList=9_12_,testtask=2,projectID=1,buildID=1
params
:=
fmt
.
Sprintf
(
"caseID=%s,version=0,resultID=%s,runID=
%s
,stepIdList=%s"
,
bug
.
Case
,
bug
.
Result
,
idInTask
,
stepIds
)
params
:=
fmt
.
Sprintf
(
"caseID=%s,version=0,resultID=%s,runID=
0
,stepIdList=%s"
,
bug
.
Case
,
bug
.
Result
,
stepIds
)
bug
.
Steps
=
strings
.
Replace
(
bug
.
Steps
,
" "
,
" "
,
-
1
)
if
bug
.
Testtask
!=
""
{
...
...
@@ -93,7 +94,7 @@ func SubmitBug(bug model.Bug, idInTask string, stepIds string) bool {
json
,
_
:=
simplejson
.
NewJson
([]
byte
(
body
))
msg
,
_
:=
json
.
Get
(
"message"
)
.
String
()
if
ok
&&
msg
==
""
{
logUtils
.
PrintToCmd
(
i118Utils
.
I118Prt
.
Sprintf
(
"success_to_report_bug"
,
bug
.
Case
,
idInTask
)
+
"
\n
"
)
logUtils
.
PrintToCmd
(
i118Utils
.
I118Prt
.
Sprintf
(
"success_to_report_bug"
,
bug
.
Case
)
+
"
\n
"
)
return
true
}
else
{
...
...
src/service/zentao/field.go
浏览文件 @
4774500e
...
...
@@ -18,7 +18,7 @@ func GetBugFiledOptions() {
conf
:=
configUtils
.
ReadCurrConfig
()
Login
(
conf
.
Url
,
conf
.
Account
,
conf
.
Password
)
params
:=
fmt
.
Sprintf
(
"%d-%
d"
,
conf
.
ProductId
,
conf
.
Proje
ctId
)
params
:=
fmt
.
Sprintf
(
"%d-%
0"
,
conf
.
Produ
ctId
)
url
:=
"conf.Url"
+
zentaoUtils
.
GenApiUri
(
"bug"
,
"ajaxGetBugFieldOptions"
,
params
)
dataStr
,
ok
:=
client
.
Get
(
url
,
nil
)
...
...
src/ui/page/pageReportBug.go
浏览文件 @
4774500e
...
...
@@ -26,7 +26,7 @@ func InitReportBugPage() error {
zentaoService
.
GetBugFiledOptions
()
bug
,
idInTask
,
stepIds
=
zentaoService
.
Sub
mitBug
()
bug
,
idInTask
,
stepIds
=
zentaoService
.
Com
mitBug
()
maxX
,
maxY
:=
vari
.
Cui
.
Size
()
pageWidth
:=
120
...
...
@@ -172,7 +172,7 @@ func reportBug(g *gocui.Gui, v *gocui.View) error {
bug
.
Pri
=
zentaoService
.
GetIdByName
(
priorityStr
,
vari
.
ZentaoBugFileds
.
Priorities
)
logUtils
.
PrintStructToCmd
(
bug
)
ret
:=
zentaoService
.
Sub
mitBug
(
bug
,
idInTask
,
stepIds
)
ret
:=
zentaoService
.
Com
mitBug
(
bug
,
idInTask
,
stepIds
)
if
ret
{
DestoryReportBugPage
()
...
...
src/utils/config/config.go
浏览文件 @
4774500e
...
...
@@ -113,6 +113,10 @@ func ConfigForDir(dir *string, entity string) {
*
dir
=
getInput
(
"is_dir"
,
"enter_dir"
,
i118Utils
.
I118Prt
.
Sprintf
(
entity
))
}
func
ConfigForInt
(
in
*
string
,
entity
string
)
{
*
in
=
getInput
(
"
\\
d+"
,
"enter_id"
,
i118Utils
.
I118Prt
.
Sprintf
(
entity
))
}
func
getInput
(
regx
string
,
fmtStr
string
,
params
...
interface
{})
string
{
var
ret
string
...
...
src/utils/const/const.go
浏览文件 @
4774500e
...
...
@@ -36,4 +36,39 @@ var (
CuiRunOutputView
=
"panelFileContent"
RequestTypePathInfo
=
"PATH_INFO"
Usage
=
`
help 查看使用帮助。
set 全局设置语言、禅道站点连接参数。
co checkout 导出禅道系统中的用例,已存在的将更新标题和步骤描述。可指定产品、套件、测试单编号。
up update 从禅道系统更新已存在的用例。可指定产品、模块、套件、测试单编号。
run 执行测试用例。可指定目录、套件、脚本、测试结果文件的路径,也支持套件和任务的编号,多个参数之间用空格隔开。
ci commit 将执行结果提交到禅道系统中。可指定测试日志目录,会弹出命令行图形界面。
bug 将执行结果中的失败用例,作为缺陷提交到餐到系统。可指定测试日志目录和用例编号,弹出命令行图形界面。
ls list 查看测试用例列表。可指定目录和文件的列表,之间用空格隔开。
view 查看测试用例详情。可指定目录和文件的列表,之间用空格隔开。
`
Example
=
`
$>atf.exe run -f scripts-demo/tc-01.bat 执行本项目自带的测试用,非windows系统使用tc-01.sh脚本
$>atf.exe co 交互式导出测试用例,将提示用户输入导出类型和编号。
$>atf.exe co -p 1 -l python 从禅道导出编号为1的产品测试用例,使用python语言。
$>atf.exe co -p 1 -m 16 -l python 从禅道导出产品编号为1、模块编号为16的测试用例。
$>atf.exe co -s 1 -l python 从禅道导出编号为1的套件所含测试用例。
$>atf.exe co -t 1 -l python 从禅道导出编号为1的测试单所含用例。
$>atf.exe run dir1 dir2 tc01.py 执行目录dir1和dir2目录下,以及tc01.py文件的用例
$>atf.exe run c:\scripts -s 1 执行禅道系统中编号为1的套件所含用例,脚本在目录c:\scripts中
$>atf.exe run c:\scripts -s all.cs 执行本机all.cs套件下的所有用例
$>atf.exe run c:\scripts -t 1 执行禅道系统中编号为1的任务所含用例
$>atf.exe run c:\scripts -r c:\19-08-27\result.txt 执行指定结果文件中失败的用例,脚本在目录c:\scripts中
$>atf.exe ci logs/2019-08-28T164819 提交指定路径的测试结果到禅道系统
$>atf.exe bug logs/2019-08-28T164819 -c 16 将测试结果中失败的用例提交为缺陷
$>atf.exe list dir1 . 列出目录dir1,以及当前目录下的所有脚本文件
$>atf.exe view tc01.py tc02.py 查看指定路径的测试脚本
`
)
src/utils/log/print.go
浏览文件 @
4774500e
...
...
@@ -3,6 +3,7 @@ package logUtils
import
(
"encoding/json"
"fmt"
constant
"github.com/easysoft/zentaoatf/src/utils/const"
stringUtils
"github.com/easysoft/zentaoatf/src/utils/string"
"github.com/easysoft/zentaoatf/src/utils/vari"
"github.com/fatih/color"
...
...
@@ -10,44 +11,11 @@ import (
)
func
PrintUsage
()
{
usage
:=
`
help 查看使用帮助。
set 全局设置语言、禅道站点连接参数。
co checkout 导出禅道系统中的用例,已存在的将更新标题和步骤描述。可指定产品、套件、测试单编号。
up update 从禅道系统更新已存在的用例。可指定产品、模块、套件、测试单编号。
run 执行测试用例。可指定目录、套件、脚本、测试结果文件的路径,也支持套件和任务的编号,多个参数之间用空格隔开。
ci commit 将执行结果提交到禅道系统中。可指定测试日志目录,会弹出命令行图形界面。
bug 将执行结果中的失败用例,作为缺陷提交到餐到系统。可指定测试日志目录和用例编号,弹出命令行图形界面。
ls list 查看测试用例列表。可指定目录和文件的列表,之间用空格隔开。
view 查看测试用例详情。可指定目录和文件的列表,之间用空格隔开。
`
example
:=
`
$>atf.exe run -f scripts-demo/tc-01.bat 执行本项目自带的测试用,非windows系统使用tc-01.sh脚本
$>atf.exe co 交互式导出测试用例,将提示用户输入导出类型和编号。
$>atf.exe co -p 1 -l python 从禅道导出编号为1的产品测试用例,使用python语言。
$>atf.exe co -p 1 -m 16 -l python 从禅道导出产品编号为1、模块编号为16的测试用例。
$>atf.exe co -s 1 -l python 从禅道导出编号为1的套件所含测试用例。
$>atf.exe co -t 1 -l python 从禅道导出编号为1的测试单所含用例。
$>atf.exe run dir1 dir2 tc01.py 执行目录dir1和dir2目录下,以及tc01.py文件的用例
$>atf.exe run c:\scripts -s 1 执行禅道系统中编号为1的套件所含用例,脚本在目录c:\scripts中
$>atf.exe run c:\scripts -s all.cs 执行本机all.cs套件下的所有用例
$>atf.exe run c:\scripts -t 1 执行禅道系统中编号为1的任务所含用例
$>atf.exe run c:\scripts -r c:\19-08-27\result.txt 执行指定结果文件中失败的用例,脚本在目录c:\scripts中
$>atf.exe list dir1 . 列出目录dir1,以及当前目录下的所有脚本文件
$>atf.exe view tc01.py tc02.py 查看指定路径的测试脚本
`
fmt
.
Println
(
color
.
CyanString
(
"
\n
Usage: "
))
fmt
.
Fprintf
(
color
.
Output
,
"%s
\n
"
,
u
sage
)
fmt
.
Fprintf
(
color
.
Output
,
"%s
\n
"
,
constant
.
U
sage
)
fmt
.
Println
(
color
.
CyanString
(
"Example: "
))
fmt
.
Fprintf
(
color
.
Output
,
"%s
\n
"
,
e
xample
)
fmt
.
Fprintf
(
color
.
Output
,
"%s
\n
"
,
constant
.
E
xample
)
}
func
PrintToSide
(
msg
string
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录