Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
54021d03
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
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 搜索 >>
提交
54021d03
编写于
8月 28, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save test cases in module dit
上级
0c700cc4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
131 addition
and
50 deletion
+131
-50
res/messages_en.json
res/messages_en.json
+16
-0
res/messages_zh.json
res/messages_zh.json
+16
-1
src/action/gen.go
src/action/gen.go
+8
-17
src/service/script/generator.go
src/service/script/generator.go
+4
-3
src/test/test.go
src/test/test.go
+5
-6
src/utils/config/config.go
src/utils/config/config.go
+51
-21
src/utils/langUtils/lang.go
src/utils/langUtils/lang.go
+31
-2
未找到文件。
res/messages_en.json
浏览文件 @
54021d03
...
...
@@ -41,6 +41,22 @@
"message"
:
"enter password"
,
"translation"
:
"enter password"
},
{
"id"
:
"enter_co_type"
,
"message"
:
"enter co type"
,
"translation"
:
"select case source? Product / Module / Suite / Task"
},
{
"id"
:
"enter_co_independent"
,
"message"
:
"enter co independent"
,
"translation"
:
"save expect results in independent file? Yes / No"
},
{
"id"
:
"enter_co_language"
,
"message"
:
"enter co language"
,
"translation"
:
"select script language. %s"
},
{
"id"
:
"invalid_input"
,
"message"
:
"invalid input"
,
...
...
res/messages_zh.json
浏览文件 @
54021d03
...
...
@@ -14,7 +14,7 @@
{
"id"
:
"enter_language"
,
"message"
:
"enter language"
,
"translation"
:
"请输入你期望使用的语言
,
En / Zh"
"translation"
:
"请输入你期望使用的语言
。
En / Zh"
},
{
"id"
:
"config_zentao_site"
,
...
...
@@ -36,6 +36,21 @@
"message"
:
"enter password"
,
"translation"
:
"请输入账号密码"
},
{
"id"
:
"enter_co_type"
,
"message"
:
"enter co type"
,
"translation"
:
"请选择用例来源。Product / Module / Suite / Task"
},
{
"id"
:
"enter_co_independent"
,
"message"
:
"enter co independent"
,
"translation"
:
"是否将用例期待结果保存在独立的文件中?Yes / No"
},
{
"id"
:
"enter_co_language"
,
"message"
:
"enter co language"
,
"translation"
:
"请选择脚本语言。 %s"
},
{
"id"
:
"invalid_input"
,
"message"
:
"invalid input"
,
...
...
src/action/gen.go
浏览文件 @
54021d03
...
...
@@ -6,31 +6,22 @@ import (
"github.com/easysoft/zentaoatf/src/utils/config"
"github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/langUtils"
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/fatih/color"
)
func
GenerateScript
(
productId
string
,
moduleId
string
,
suiteId
string
,
taskId
string
,
independentFile
bool
,
scriptLang
string
)
{
LangMap
:=
scriptService
.
GetSupportedScriptLang
()
langs
:=
""
if
LangMap
[
scriptLang
]
==
nil
{
i
:=
0
for
lang
,
_
:=
range
LangMap
{
if
i
>
0
{
langs
+=
", "
}
langs
+=
lang
i
++
}
logUtils
.
PrintToCmd
(
color
.
RedString
(
i118Utils
.
I118Prt
.
Sprintf
(
"only_support_script_language"
,
langs
))
+
"
\n
"
)
return
config
:=
configUtils
.
ReadCurrConfig
()
if
config
.
Url
==
""
||
config
.
Account
==
""
||
config
.
Password
==
""
{
configUtils
.
ConfigForCheckout
(
&
productId
,
&
moduleId
,
&
suiteId
,
&
taskId
,
&
independentFile
,
&
scriptLang
)
}
config
:=
configUtils
.
ReadCurrConfig
(
)
if
config
.
Url
==
""
{
configUtils
.
ConfigForCheckout
()
ok
:=
langUtils
.
CheckSupportLangages
(
scriptLang
)
if
!
ok
{
return
}
cases
:=
zentaoService
.
LoadTestCases
(
productId
,
moduleId
,
suiteId
,
taskId
)
...
...
src/service/script/generator.go
浏览文件 @
54021d03
...
...
@@ -6,6 +6,7 @@ import (
constant
"github.com/easysoft/zentaoatf/src/utils/const"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/langUtils"
"github.com/easysoft/zentaoatf/src/utils/vari"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
"os"
...
...
@@ -36,7 +37,7 @@ func GenerateTestCaseScript(cs model.TestCase, langType string, independentFile
modulePath
=
modulePath
[
1
:
]
}
scriptFile
:=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"%stc-%s.%s"
,
modulePath
,
caseId
,
LangMap
[
langType
][
"extName"
])
scriptFile
:=
fmt
.
Sprintf
(
constant
.
ScriptDir
+
"%stc-%s.%s"
,
modulePath
,
caseId
,
langUtils
.
LangMap
[
langType
][
"extName"
])
fileUtils
.
MkDirIfNeeded
(
constant
.
ScriptDir
)
*
caseIds
=
append
(
*
caseIds
,
caseId
)
...
...
@@ -71,7 +72,7 @@ func GenerateTestCaseScript(cs model.TestCase, langType string, independentFile
return
}
temp
:=
fmt
.
Sprintf
(
"
\n
%sCODE: %s"
,
LangMap
[
langType
][
"commentsTag"
],
temp
:=
fmt
.
Sprintf
(
"
\n
%sCODE: %s"
,
langUtils
.
LangMap
[
langType
][
"commentsTag"
],
i118Utils
.
I118Prt
.
Sprintf
(
"your_codes_here"
))
srcCode
=
append
(
srcCode
,
temp
)
...
...
@@ -101,7 +102,7 @@ func GenerateTestCaseScript(cs model.TestCase, langType string, independentFile
func
GenerateTestStepScript
(
ts
model
.
TestStep
,
langType
string
,
stepWidth
int
,
steps
*
[]
string
,
expects
*
[]
string
,
srcCode
*
[]
string
)
{
LangMap
:=
GetSupportedScriptLang
()
LangMap
:=
langUtils
.
GetSupportedScriptLang
()
isGroup
:=
ts
.
Type
==
"group"
isCheckPoint
:=
ts
.
Expect
!=
""
...
...
src/test/test.go
浏览文件 @
54021d03
package
main
import
(
"flag"
"fmt"
commonUtils
"github.com/easysoft/zentaoatf/src/utils/common"
"github.com/easysoft/zentaoatf/src/utils/langUtils"
"strings"
)
func
main
()
{
var
languages
[]
string
flag
.
Var
(
commonUtils
.
NewSliceValue
([]
string
{},
&
languages
),
"slice"
,
"I like programming `languages`"
)
flag
.
Parse
()
fmtParam
:=
strings
.
Join
(
langUtils
.
GetSupportLangageArr
(),
" / "
)
scriptLang
:=
fmt
.
Sprintf
(
"enter_co_language%s"
,
fmtParam
)
fmt
.
Println
(
languages
)
fmt
.
Println
(
scriptLang
)
}
src/utils/config/config.go
浏览文件 @
54021d03
...
...
@@ -8,6 +8,7 @@ import (
"github.com/easysoft/zentaoatf/src/utils/display"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
"github.com/easysoft/zentaoatf/src/utils/i118"
"github.com/easysoft/zentaoatf/src/utils/langUtils"
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/easysoft/zentaoatf/src/utils/vari"
"github.com/fatih/color"
...
...
@@ -45,18 +46,18 @@ func ConfigForSet() {
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"begin_config"
))
language
=
getInput
(
"
enter_language"
,
"(english|chinese|e|c)
"
)
language
=
getInput
(
"
(english|chinese|e|c)"
,
"enter_language
"
)
if
strings
.
Index
(
strings
.
ToLower
(
language
),
"e"
)
==
0
{
language
=
"en"
}
else
{
language
=
"zh"
}
configSite
=
getInput
(
"
config_zentao_site"
,
"(yes|no|y|n)
"
)
configSite
=
getInput
(
"
(yes|no|y|n)"
,
"config_zentao_site
"
)
if
strings
.
Index
(
configSite
,
"y"
)
==
0
{
url
=
getInput
(
"
enter_url"
,
"http://.*
"
)
account
=
getInput
(
"
enter_account"
,
".{3,}
"
)
password
=
getInput
(
"
enter_password"
,
".{4,}
"
)
url
=
getInput
(
"
http://.*"
,
"enter_url
"
)
account
=
getInput
(
"
.{3,}"
,
"enter_account
"
)
password
=
getInput
(
"
.{4,}"
,
"enter_password
"
)
}
SaveConfig
(
language
,
url
,
account
,
password
)
...
...
@@ -64,32 +65,58 @@ func ConfigForSet() {
PrintCurrConfig
()
}
func
ConfigForCheckout
()
{
language
:=
""
url
:=
""
account
:=
""
password
:=
""
func
ConfigForCheckout
(
productId
*
string
,
moduleId
*
string
,
suiteId
*
string
,
taskId
*
string
,
independentFile
*
bool
,
scriptLang
*
string
)
{
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"need_config"
))
color
.
Cyan
(
"
\n
"
+
i118Utils
.
I118Prt
.
Sprintf
(
"need_config"
))
url
=
getInput
(
"enter_url"
,
"http://.*
"
)
account
=
getInput
(
"enter_account"
,
".{3,}
"
)
password
=
getInput
(
"enter_password"
,
".{4,}
"
)
url
:=
getInput
(
"http://.*"
,
"enter_url
"
)
account
:=
getInput
(
".{3,}"
,
"enter_account
"
)
password
:=
getInput
(
".{4,}"
,
"enter_password
"
)
SaveConfig
(
language
,
url
,
account
,
password
)
coType
:=
getInput
(
"(product|module|suite|task|p|m|s|t)"
,
"enter_co_type"
)
coType
=
strings
.
ToLower
(
coType
)
if
coType
==
"product"
||
coType
==
"p"
{
*
productId
=
getInput
(
"
\\
d+"
,
"productId"
)
}
else
if
coType
==
"module"
||
coType
==
"m"
{
*
productId
=
getInput
(
"
\\
d+"
,
"productId"
)
*
moduleId
=
getInput
(
"
\\
d+"
,
"moduleId"
)
}
else
if
coType
==
"suite"
||
coType
==
"s"
{
*
suiteId
=
getInput
(
"
\\
d+"
,
"suiteId"
)
}
else
if
coType
==
"task"
||
coType
==
"t"
{
*
taskId
=
getInput
(
"
\\
d+"
,
"taskId"
)
}
indep
:=
getInput
(
"(yes|no|y|n)"
,
"enter_co_independent"
)
regx
:=
"("
+
strings
.
Join
(
langUtils
.
GetSupportLangageArr
(),
"|"
)
+
")"
fmtParam
:=
strings
.
Join
(
langUtils
.
GetSupportLangageArr
(),
" / "
)
*
scriptLang
=
getInput
(
regx
,
"enter_co_language"
,
fmtParam
)
indep
=
strings
.
ToLower
(
indep
)
if
indep
==
"yes"
||
indep
==
"y"
{
*
independentFile
=
true
}
else
{
*
independentFile
=
false
}
SaveConfig
(
"en"
,
url
,
account
,
password
)
PrintCurrConfig
()
}
func
getInput
(
msg
string
,
regx
string
)
string
{
func
getInput
(
regx
string
,
fmtStr
string
,
params
...
interface
{}
)
string
{
var
ret
string
msg
:=
i118Utils
.
I118Prt
.
Sprintf
(
fmtStr
,
params
...
)
for
{
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
msg
)
+
":
"
)
color
.
Cyan
(
"
\n
"
+
msg
+
"
\n
"
)
fmt
.
Scanln
(
&
ret
)
ret
=
strings
.
ToLower
(
ret
)
if
ret
==
"exit"
{
temp
:
=
strings
.
ToLower
(
ret
)
if
temp
==
"exit"
{
os
.
Exit
(
1
)
}
...
...
@@ -97,7 +124,7 @@ func getInput(msg string, regx string) string {
return
ret
}
pass
,
_
:=
regexp
.
MatchString
(
regx
,
ret
)
pass
,
_
:=
regexp
.
MatchString
(
"^"
+
regx
+
"$"
,
temp
)
if
pass
{
return
ret
}
else
{
...
...
@@ -211,7 +238,10 @@ func ReadCurrConfig() model.Config {
}
func
saveEmptyConfig
()
error
{
SaveConfig
(
"en"
,
""
,
""
,
""
)
config
:=
model
.
Config
{
Language
:
"en"
,
Url
:
""
,
Account
:
""
,
Password
:
""
}
data
,
_
:=
yaml
.
Marshal
(
&
config
)
ioutil
.
WriteFile
(
constant
.
ConfigFile
,
data
,
0666
)
return
nil
}
src/
service/script
/lang.go
→
src/
utils/langUtils
/lang.go
浏览文件 @
54021d03
package
scriptService
package
langUtils
import
"sync"
import
(
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
"github.com/fatih/color"
"strings"
"sync"
)
var
LangMap
map
[
string
]
map
[
string
]
string
...
...
@@ -59,6 +65,29 @@ func GetSupportedScriptLang() map[string]map[string]string {
return
LangMap
}
func
GetSupportLangageArr
()
[]
string
{
langMap
:=
GetSupportedScriptLang
()
arr
:=
make
([]
string
,
0
)
for
lang
,
_
:=
range
langMap
{
arr
=
append
(
arr
,
lang
)
}
return
arr
}
func
CheckSupportLangages
(
scriptLang
string
)
bool
{
langMap
:=
GetSupportedScriptLang
()
if
langMap
[
scriptLang
]
==
nil
{
langs
:=
strings
.
Join
(
GetSupportLangageArr
(),
", "
)
logUtils
.
PrintToCmd
(
color
.
RedString
(
i118Utils
.
I118Prt
.
Sprintf
(
"only_support_script_language"
,
langs
))
+
"
\n
"
)
return
false
}
return
true
}
func
init
()
{
GetSupportedScriptLang
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录