惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
B
Blog
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Y
Y Combinator Blog
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
Recent Announcements
Recent Announcements
U
Unit 42
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
Recorded Future
Recorded Future
C
Check Point Blog
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Full Disclosure
小众软件
小众软件
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
爱范儿
爱范儿
P
Proofpoint News Feed
罗磊的独立博客
量子位
D
Docker
博客园_首页
D
DataBreaches.Net
Project Zero
Project Zero
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
Security Latest
Security Latest
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
Netflix TechBlog - Medium
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏

博客园 - stonespawn

Vue 组件库2 Vue 的组件库 算法小题目 VS2019 自动代码补全功能 GIT 删除操作 vue-router 注意事项 Vue中axios访问 后端跨域问题 Vue2.0 搭配 axios Vue 脚手架搭建 grunt使用入门 Git相关操作及记录 Ajax在调用含有SoapHeader的webservice方法 关于JS 树形结构 导出EXCEL【Web方式HTML通过拼接html中table】 链接点击跳动问题 WatiN——Web自动化测试(三)【弹出窗口处理】 WatiN——Web自动化测试(一) 网页调用服务程序 - stonespawn - 博客园 小问题 小技巧 :创建虚拟目录并将IIS里面.net配置版本设为2.0 - stonespawn
WatiN——Web自动化测试(二)
stonespawn · 2011-04-06 · via 博客园 - stonespawn

    利用WatiN进行自动化测试,并不仅仅的将代码堆放在一起就OK了,对于一个成熟的公司,有相对较为稳定的测试流程;那么对于我们来说,需要设计

一个较为清晰的结构才能应对测试流程和管理测试用例,如何设计测试用例的框架?比如测试一个用户注册然后登录,进入页面之后,再创建一条记录。因长的测试

流程中肯定有功能相似的代码部分,例如登录或者是新增一条记录。如何去编制cases?细分的原则又是什么呢?

1、TestCases和TestSuite关系

(1)TestSuite相当于Case的模块,大量的Case存放肯定是需要划分母块的,否则就难以查询和维护、和实时更新。

(2)TestSuite和TestCase关系图

2、定义测试用例基类TestCasesBase,其内容如下

public abstract class TestCasesBase
{
/// <summary>
/// 测试用例名称
/// </summary>
public string CaseDescription = string.Empty;

protected TestContext context;

//初始化TestCases级的环境
public virtual void SetUp()
{
}

//清除TestCases级产生的垃圾
public virtual void TearDown()
{
if (context.Browser != null)
{
context.Browser.Close();
context.Browser.Dispose();
context.Browser = null;
}
}

//这个方法必须在TC中实现
public virtual void TestBody()
{
}

//这个方法不需要在TC实现
public virtual void Run(TestContext tcContext)
{
context = tcContext;
SetUp();
TestBody();
TearDown();
}
}

3、定义测试用例基类模块TestSuiteBase,其内容如下

public abstract class TestSuiteBase : ILogger
{
//初始化testsuite级的环境
public virtual void SetUpTestCase(TestContext testContext)
{
}

//清除testsuite级产生的垃圾
public virtual void TearDownTestCase(TestContext testContext)
{
}

public abstract void RunTestCase(TestContext testContext);

}

TestCase中所包含的主要方法是:SetUp、TestBody、TearDown;

(1)SetUp是运行TestCase前所需要的参数和运行准备,例如有的Case可能需要配置一些文件,有的可能需要数据表等等

(2)TestBody是测试用例的主体部分,是操作网页中的元素

(3)TearDown是测试用例的清理工作,相当于TestBody打过仗,TearDown进行善后工作;例如经常自动化,那么数据库里的冗余数据非常的多,需要每次执行的以后进行清理工作

TestSuite中所包含的主要方法是:SetUpTestCase、RunTestCase、TearDownTestCase;

(1)SetUpTestCase是运行TestSuite前所需要的参数和运行准备

(2)RunTestCase是运行多测试用例

(3)TearDownTestCase是运行TestSuite后的清理工作

4、扩展

其实TestSuite和TestCase原本并非需要这样组织,完全可以合成一个测试用例进行执行,但是Case的颗粒度过大,无法有效合理的对Case进行管理。在大

的项目中,其实Case的颗粒度要远远的大于以上所涉及到的。一个测试用例可能包括很多个步骤。那又个如何进行分割呢?如何进行有效的管理和合理利用? 如下图:

当设计到的测试用例过于复杂时,我们则需要将测试用例进行level的划分,理论上可以无限极的划分下去,这样以便于我们更有效的管理和维护;更有效的

是代码的重用,例如:RegisterTC(注册测试用例)可能在不同的TestSuite都有可能用到,那么在其他的TestSuite下,可能只需要list.Add(RegisterTC())

将用例加入list中即可。这次写的比较混乱,也不知道说明白了没有,希望大家拍砖!