Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
content
全程软件测试(第3版)
提交
94d2e73c
全
全程软件测试(第3版)
项目概览
CSDN 技术社区
/
content
/
全程软件测试(第3版)
通知
8
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
全
全程软件测试(第3版)
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
94d2e73c
编写于
12月 22, 2021
作者:
ToTensor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add code file
上级
38150577
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
283 addition
and
0 deletion
+283
-0
data/全程软件测试(第3版)/第02章 全程测试:闪光的思想/2.2 测试驱动开发/code_1.java
data/全程软件测试(第3版)/第02章 全程测试:闪光的思想/2.2 测试驱动开发/code_1.java
+17
-0
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_1.java
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_1.java
+23
-0
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_2.java
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_2.java
+18
-0
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_3.java
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_3.java
+5
-0
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_4.java
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_4.java
+28
-0
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_5.java
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_5.java
+8
-0
main.py
main.py
+4
-0
src/ebook/ebook_get_request.py
src/ebook/ebook_get_request.py
+44
-0
src/ebook/extract_book_code.py
src/ebook/extract_book_code.py
+118
-0
src/ebook/get_book_chapter_id_list.py
src/ebook/get_book_chapter_id_list.py
+18
-0
未找到文件。
data/全程软件测试(第3版)/第02章 全程测试:闪光的思想/2.2 测试驱动开发/code_1.java
0 → 100644
浏览文件 @
94d2e73c
Title
(
one
line
describing
the
story
)
Narrative:
As
a
[
role
]
I
want
[
feature
]
So
that
[
benefit
]
Acceptance
criteria:
(
presented
as
Scenarios
)
Scenario
1
:
Title
Given
[
context
]
And
[
some
more
context
]...
When
[
event
]
Then
[
outcome
]
And
[
another
outcome
]...
Scenario
2
:
...
\ No newline at end of file
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_1.java
0 → 100644
浏览文件 @
94d2e73c
public
static
void
main
(
String
[]
args
)
{
// 首先创建一个 FireFox 浏览器webdriver的实例,并让浏览器访问必应
WebDriver
driver
=
new
FirefoxDriver
();
driver
.
get
(
"http://cn.bing.com"
);
// 获取页面的 title
System
.
out
.
println
(
"Home Page title: "
+
driver
.
getTitle
());
// 通过id找到input的web UI元素,并在此域内输入“软件测试”,并提交
WebElement
element
=
driver
.
findElement
(
By
.
id
(
"sb_form_q"
));
// 或通过xPath来定位web元素
// element = driver.findElement(By.xpath("*[@id='sb_form_q']"))
// 在此域内输入“软件测试”,并提交
element
.
sendKeys
(
“
软件测试
”
);
element
.
submit
();
// 通过判断 title 内容等待搜索页面加载完毕
(
new
WebDriverWait
(
driver
,
10
)).
until
(
new
ExpectedCondition
()
{
public
Boolean
apply
(
WebDriver
d
)
{
return
d
.
getTitle
().
toLowerCase
().
endsWith
(
“
软件测试
”
);
}
});
System
.
out
.
println
(
"Result Page title: "
+
driver
.
getTitle
());
driver
.
quit
();
}
\ No newline at end of file
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_2.java
0 → 100644
浏览文件 @
94d2e73c
4.0
.
0
MySel20Proj
MySel20Proj
1.0
org
.
seleniumhq
.
selenium
selenium
-
java
2.53
.
0
org
.
seleniumhq
.
selenium
htmlunit
-
driver
2.20
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_3.java
0 → 100644
浏览文件 @
94d2e73c
java
-
jar
selenium
-
server
-
standalone
-
x
.
xx
.
x
.
jar
-
role
hub
java
-
jar
selenium
-
server
-
standalone
-
x
.
xx
.
x
.
jar
-
role
node
-
port
5551
java
-
jar
selenium
-
server
-
standalone
-
x
.
xx
.
x
.
jar
-
role
node
-
port
5552
……
\ No newline at end of file
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_4.java
0 → 100644
浏览文件 @
94d2e73c
public
class
EditorTest
extends
ActivityInstrumentationTestCase2
{
private
Solo
solo
;
public
EditorTest
(){
super
(
EditorActivity
.
class
);
}
public
void
setUp
()
throws
Exception
{
solo
=
new
Solo
(
getInstrumentation
(),
getActivity
());
}
public
void
testPreferenceIsSaved
()
throws
Exception
{
solo
.
sendKey
(
Solo
.
MENU
);
solo
.
clickOnText
(
"More"
);
solo
.
clickOnText
(
"Preferences"
);
solo
.
clickOnText
(
"Edit File Extensions"
)
solo
.
clickOnText
(
solo
.
searchText
(
"rtf"
));
solo
.
clickOnText
(
"txt"
);
solo
.
clearEditText
(
2
);
solo
.
enterText
(
2
,
"robotium"
);
solo
.
clickOnButton
(
"Save"
);
solo
.
goBack
();
solo
.
clickOnText
(
"Edit File Extensions"
);
Assert
.
assertTrue
(
solo
.
searchText
(
"application/robotium"
));
}
@Override
public
void
tearDown
()
throws
Exception
{
solo
.
finishOpenedActivities
();
}
\ No newline at end of file
data/全程软件测试(第3版)/第03章 准备:基础设施与TA框架/3.4 自动化测试框架/code_5.java
0 → 100644
浏览文件 @
94d2e73c
Feature:
Refund
item
Scenario:
Jeff
returns
a
faulty
microwave
Given
Jeff
has
bought
a
microwave
for
$
100
And
he
has
a
receipt
When
he
returns
the
microwave
Then
Jeff
should
be
refunded
$
100
\ No newline at end of file
main.py
0 → 100644
浏览文件 @
94d2e73c
from
src.ebook.extract_book_code
import
extract_code
if
__name__
==
"__main__"
:
extract_code
()
src/ebook/ebook_get_request.py
0 → 100644
浏览文件 @
94d2e73c
import
json
import
requests
import
logging
logger
=
logging
.
getLogger
(
__name__
)
def
get_chapter_content
(
params
):
url
=
'http://192.168.50.117:9003/v1/chapter/content'
headers
=
{
"Cookie"
:
"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
}
result
=
requests
.
get
(
url
=
url
,
params
=
params
,
headers
=
headers
)
if
result
.
status_code
==
200
:
ret
=
json
.
loads
(
result
.
text
)
logger
.
info
(
'request success'
)
content
=
ret
[
'data'
]
return
content
else
:
logger
.
info
(
'request failed!!!!!'
)
return
{}
def
get_chapter_list
(
params
):
url
=
'http://192.168.50.117:9003/inner/v1/chapter/list'
headers
=
{
"Cookie"
:
"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
}
result
=
requests
.
get
(
url
=
url
,
params
=
params
,
headers
=
headers
)
if
result
.
status_code
==
200
:
ret
=
json
.
loads
(
result
.
text
)
logger
.
info
(
'request success'
)
content
=
ret
[
'data'
]
return
content
else
:
logger
.
info
(
'request failed!!!!!'
)
return
{}
\ No newline at end of file
src/ebook/extract_book_code.py
0 → 100644
浏览文件 @
94d2e73c
import
json
import
os
import
re
import
html
from
bs4
import
BeautifulSoup
from
.get_book_chapter_id_list
import
get_chapter_id_list
from
.ebook_get_request
import
get_chapter_content
def
extract_code
():
book_mapping_path
=
"data/book_mapping.json"
with
open
(
book_mapping_path
,
"r"
)
as
f
:
book_mapping
=
json
.
load
(
f
)
for
book_idx
,
book_name
in
enumerate
(
book_mapping
.
keys
()):
if
book_name
==
'Python编程无师自通'
:
continue
book_dir_name
=
'{}.{}'
.
format
(
book_idx
+
1
,
book_name
)
book_dir
=
os
.
path
.
join
(
'data/books'
,
book_dir_name
)
if
not
os
.
path
.
exists
(
book_dir
):
os
.
mkdir
(
book_dir
)
print
(
book_dir_name
)
book_id
=
book_mapping
[
book_name
]
request_get_chapter_id_list_params
=
{
"bookId"
:
book_id
,
"is_main"
:
1
}
chapter_id_list
=
get_chapter_id_list
(
request_get_chapter_id_list_params
)
print
(
chapter_id_list
)
for
chapter_id
in
chapter_id_list
:
request_get_chapter_content_params
=
{
'bookId'
:
book_id
,
'chapterId'
:
chapter_id
}
chapter_resp
=
get_chapter_content
(
request_get_chapter_content_params
)
chapter_name
=
chapter_resp
[
'name'
]
chapter_content
=
chapter_resp
[
'content'
]
try
:
if
book_name
==
"零基础学机器学习"
:
chapter_num
=
re
.
findall
(
r
'第(.*)课'
,
chapter_name
)[
0
]
chapter_name_modify
=
re
.
sub
(
r
'第(.*)课'
,
r
'第{}课'
.
format
(
chapter_num
.
zfill
(
2
)),
chapter_name
)
else
:
chapter_num
=
re
.
findall
(
r
'第(.*)章'
,
chapter_name
)[
0
]
chapter_name_modify
=
re
.
sub
(
r
'第(.*)章'
,
r
'第{}章'
.
format
(
chapter_num
.
zfill
(
2
)),
chapter_name
)
chapter_name
=
chapter_name_modify
except
:
# print('该章节没有章节序号: {}'.format(chapter_name))
pass
chapter_dir
=
os
.
path
.
join
(
book_dir
,
chapter_name
)
if
not
os
.
path
.
exists
(
chapter_dir
):
os
.
mkdir
(
chapter_dir
)
# print('创建文件夹: {}'.format(chapter_dir))
chapter_content
=
html
.
unescape
(
chapter_content
)
if
book_name
==
"全程软件测试(第3版)"
:
section_list
=
re
.
findall
(
r
'<h2.*>(.*?)</h2>'
,
chapter_content
)
section_content_list
=
re
.
split
(
r
'<h2.*?>.*?</h2>'
,
chapter_content
,
flags
=
re
.
S
)
section_dir_list
=
[]
for
section
in
section_list
:
section
=
section
.
replace
(
' '
,
' '
)
if
section
.
find
(
r
'/'
)
!=
-
1
:
section
=
section
.
replace
(
'/'
,
''
)
section_dir
=
os
.
path
.
join
(
chapter_dir
,
section
)
print
(
section_dir
)
if
not
os
.
path
.
exists
(
section_dir
):
os
.
mkdir
(
section_dir
)
section_dir_list
.
append
(
section_dir
)
for
idx
,
section_content
in
enumerate
(
section_content_list
):
if
idx
==
0
:
save_dir
=
os
.
path
.
join
(
chapter_dir
,
'text.html'
)
else
:
save_dir
=
os
.
path
.
join
(
section_dir_list
[
idx
-
1
],
'text.html'
)
code_list
=
re
.
findall
(
r
'<code>(.*?)</code>'
,
section_content
,
re
.
S
)
res_code_list
=
[]
count
=
0
for
i
in
code_list
:
if
len
(
i
.
split
(
'
\n
'
))
<
2
:
continue
count
+=
1
i
=
html
.
unescape
(
i
)
soup
=
BeautifulSoup
(
i
)
res_str
=
soup
.
get_text
()
if
idx
==
0
:
code_save_dir
=
os
.
path
.
join
(
chapter_dir
,
'code_0.java'
)
else
:
code_save_dir
=
os
.
path
.
join
(
section_dir_list
[
idx
-
1
],
'code_{}.java'
.
format
(
count
))
print
(
res_str
)
with
open
(
code_save_dir
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
res_str
)
# clean_text_list = []
# for line in res_str.split('\n'):
# if line == '':
# continue
# if line[0].isdigit():
# line = re.findall(r'^[0-9]+ {0,2}(.*)',
# line)[0]
# # print(line)
# else:
# if line.startswith('>>'):
# break
# clean_text_list.append(line)
# clean_code = '\n'.join(clean_text_list)
# print(clean_code)
\ No newline at end of file
src/ebook/get_book_chapter_id_list.py
0 → 100644
浏览文件 @
94d2e73c
import
json
import
re
import
html
import
nltk
import
html2text
import
os
import
pandas
as
pd
from
bs4
import
BeautifulSoup
from
.ebook_get_request
import
get_chapter_list
def
get_chapter_id_list
(
param
):
chapter_list
=
[]
ret
=
get_chapter_list
(
param
)
for
item
in
ret
:
chapterid
=
item
[
'chapterid'
]
chapter_list
.
append
(
chapterid
)
return
chapter_list
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录