Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
4304947a
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 搜索 >>
提交
4304947a
编写于
7月 09, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
generate test scripts from sample manual testcase
上级
82c462f3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
43 deletion
+45
-43
src/gen-project.go
src/gen-project.go
+13
-43
src/model/test-model.go
src/model/test-model.go
+20
-0
src/utils/utils.go
src/utils/utils.go
+12
-0
未找到文件。
src/gen-project.go
浏览文件 @
4304947a
...
...
@@ -3,49 +3,20 @@ package main
import
(
"encoding/json"
"fmt"
"
io/iouti
l"
"
mode
l"
"os"
"strconv"
"strings"
"utils"
)
type
Response
struct
{
Code
int
Cases
[]
TestCase
}
type
TestCase
struct
{
Id
int
Title
string
Steps
[]
TestStep
}
type
TestStep
struct
{
Id
int
Title
string
Steps
[]
TestStep
Expect
string
IsGroup
bool
IsCheckPoint
bool
}
func
ReadAll
(
filePth
string
)
[]
byte
{
buf
,
err
:=
ioutil
.
ReadFile
(
filePth
)
if
err
!=
nil
{
return
nil
}
return
buf
}
func
DealwithTestCase
(
tc
TestCase
,
langType
string
)
{
func
DealwithTestCase
(
tc
model
.
TestCase
,
langType
string
)
{
caseId
:=
tc
.
Id
caseTitle
:=
tc
.
Title
steps
:=
[]
string
{}
expects
:=
[]
string
{}
srcCode
:=
[]
string
{}
steps
:=
make
([]
string
,
0
)
expects
:=
make
([]
string
,
0
)
srcCode
:=
make
([]
string
,
0
)
level
:=
1
...
...
@@ -53,21 +24,21 @@ func DealwithTestCase(tc TestCase, langType string) {
DealwithTestStep
(
ts
,
langType
,
level
,
&
steps
,
&
expects
,
&
srcCode
)
}
template
:=
ReadAll
(
"xdoc/script-template.txt"
)
template
:=
utils
.
ReadFile
(
"xdoc/script-template.txt"
)
content
:=
string
(
fmt
.
Sprintf
(
string
(
template
),
langType
,
caseTitle
,
caseId
,
strings
.
Join
(
steps
,
"
\n
"
),
strings
.
Join
(
expects
,
"
\n
"
),
strings
.
Join
(
srcCode
,
"
\n
"
)))
fmt
.
Println
(
content
)
}
func
DealwithTestStep
(
ts
TestStep
,
langType
string
,
level
int
,
func
DealwithTestStep
(
ts
model
.
TestStep
,
langType
string
,
level
int
,
steps
*
[]
string
,
expects
*
[]
string
,
srcCode
*
[]
string
)
{
isGroup
:=
ts
.
IsGroup
isCheckPoint
:=
ts
.
IsCheckPoint
stepId
:=
ts
.
Id
stepTitle
:=
ts
.
Title
stepExpect
:=
ts
.
Expect
//
stepExpect := ts.Expect
// 处理steps
stepLine
:=
""
...
...
@@ -94,12 +65,11 @@ func DealwithTestStep(ts TestStep, langType string, level int,
*
steps
=
append
(
*
steps
,
stepLine
)
// 处理expects
if
isCheckPoint
{
expectsLine
:=
""
expectsLine
=
"#
"
+
stepLineSimple
+
" "
+
stepExpect
+
"
\n
"
expectsLine
+=
"<
期望值字符串
, 可以有多行>
\n
"
expectsLine
=
"#
\n
"
//
+ stepLineSimple + " " + stepExpect + "\n"
expectsLine
+=
"<
"
+
stepType
+
strconv
.
Itoa
(
stepId
)
+
" 期望结果
, 可以有多行>
\n
"
*
expects
=
append
(
*
expects
,
expectsLine
)
}
...
...
@@ -128,9 +98,9 @@ func main() {
}
caseFile
,
langType
:=
os
.
Args
[
1
],
os
.
Args
[
2
]
buf
:=
ReadAll
(
caseFile
)
buf
:=
utils
.
ReadFile
(
caseFile
)
var
resp
Response
var
resp
model
.
Response
json
.
Unmarshal
(
buf
,
&
resp
)
if
resp
.
Code
!=
1
{
...
...
src/model/test-model.go
0 → 100644
浏览文件 @
4304947a
package
model
type
Response
struct
{
Code
int
Cases
[]
TestCase
}
type
TestCase
struct
{
Id
int
Title
string
Steps
[]
TestStep
}
type
TestStep
struct
{
TestCase
Expect
string
IsGroup
bool
IsCheckPoint
bool
}
src/utils/utils.go
0 → 100644
浏览文件 @
4304947a
package
utils
import
"io/ioutil"
func
ReadFile
(
filePth
string
)
[]
byte
{
buf
,
err
:=
ioutil
.
ReadFile
(
filePth
)
if
err
!=
nil
{
return
nil
}
return
buf
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录