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

submit bug

上级 52279afc
......@@ -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",
......
......@@ -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",
......
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)
}
......@@ -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 {
......
......@@ -6,7 +6,4 @@ type Config struct {
Url string
Account string
Password string
ProductId int
ProjectId int
}
......@@ -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
}
......
......@@ -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.CurrCaseId {
if cs.Id != caseId {
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, " ", "&nbsp;", -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 {
......
......@@ -18,7 +18,7 @@ func GetBugFiledOptions() {
conf := configUtils.ReadCurrConfig()
Login(conf.Url, conf.Account, conf.Password)
params := fmt.Sprintf("%d-%d", conf.ProductId, conf.ProjectId)
params := fmt.Sprintf("%d-%0", conf.ProductId)
url := "conf.Url" + zentaoUtils.GenApiUri("bug", "ajaxGetBugFieldOptions", params)
dataStr, ok := client.Get(url, nil)
......
......@@ -26,7 +26,7 @@ func InitReportBugPage() error {
zentaoService.GetBugFiledOptions()
bug, idInTask, stepIds = zentaoService.SubmitBug()
bug, idInTask, stepIds = zentaoService.CommitBug()
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.SubmitBug(bug, idInTask, stepIds)
ret := zentaoService.CommitBug(bug, idInTask, stepIds)
if ret {
DestoryReportBugPage()
......
......@@ -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
......
......@@ -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 查看指定路径的测试脚本
`
)
......@@ -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("\nUsage: "))
fmt.Fprintf(color.Output, "%s\n", usage)
fmt.Fprintf(color.Output, "%s\n", constant.Usage)
fmt.Println(color.CyanString("Example: "))
fmt.Fprintf(color.Output, "%s\n", example)
fmt.Fprintf(color.Output, "%s\n", constant.Example)
}
func PrintToSide(msg string) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册