Robot Framework 快速入门(2)

发表于:2012-02-29来源:TIB自动化测试工作室作者:TIB点击数: 标签:Robot Framew
用户使用错误密码无法登入 Test Case Action Argument Argument User can create an account and log in Create Valid User fred P4ssw0rd Attempt to Login with Credentials fred P4ssw0rd Status Sho

  用户使用错误密码无法登入

Test Case

Action

Argument

Argument

User can create an account and log in

Create Valid User

fred

P4ssw0rd

 

Attempt to Login with Credentials

fred

P4ssw0rd

 

Status Should Be

Logged In

 

 

 

 

 

User cannot log in with bad password

Create Valid User

betty

P4ssw0rd

 

Attempt to Login with Credentials

betty

wrong

 

Status Should Be

Access Denied

 

  注意 这些测试比起自动测试用例更像用英语手工写的测试。Robot Framework 使用关键词驱动的方式,支持用自然语言来编写可以抓住动作和期望值的本质的测试。测试用例由关键词(通常在第二列)和它们可能的参数组成。

  高级别测试用例

  测试用例也可以通过使用不携带参数的高级别关键词来创建。这种风格允许使用完全的自由文本以便于进行交流,即使是和非技术人员或者其他利益相关者。T Robot Framework 不强制使用任何风格来编写测试用例,它可以用于行为驱动开发behavior-driven development (BDD)推荐的given-when-then 格式的样例,如下所示。

Test Case

Steps

User can change password

Given a user has a valid account

 

when she changes her password

 

then she can log in with the new password

 

and she cannot use the old password anymore

  这种测试用例或者用户故事风格的测试用例的类型很适合用于acceptance test-driven development (ATDD). 在 ATDD 中接收测试在实现实际产品特性前编写并且他们反映了需求

  数据驱动测试用例

  通常部分测试用例除了部分不同的输入或者输出数据外都.在这些情况下数据驱动,如下面六个测试用例,允许在不复制工作流的情况下改变测试数据 。

Test Case

Action

Password

Expected error message

Too short password

Creating user with invalid password should fail

abCD5

${PWD INVALID LENGTH}

Too long password

Creating user with invalid password should fail

abCD567890123

${PWD INVALID LENGTH}

Password without lowercase letters

Creating user with invalid password should fail

123DEFG

${PWD INVALID CONTENT}

Password without capital letters

Creating user with invalid password should fail

abcd56789

${PWD INVALID CONTENT}

Password without numbers

Creating user with invalid password should fail

AbCdEfGh

${PWD INVALID CONTENT}

Password with special characters

Creating user with invalid password should fail

abCD56+

${PWD INVALID CONTENT}

原文转自:http://www.ltesting.net