2016년 3월 11일 금요일

(E, K) Robot framework, RIDE 2 - How to write good test cases using Robot Framework(Robot Framework에서 좋은 테스트 케이스는 어떻게 만드는가)

Introduction

Naming


Test suite names

  • Suite names should be as describing as possible.
  • Names are created automatically from file or directory names:
    • Extensions are stripped.
    • Underscores are converted to spaces.
    • If name is all lower case, words are capitalized.
  • Names can be relatively long, but overly long names are not convenient on the file system.
  • The name of the top level suite can be overridden from the command line using the --name option if needed.
Examples:
  • login_tests.robot -> Login Tests
  • IP_v4_and_v6 -> IP v4 and v6

Test case names

  • Test names should be describing similarly as suite names.
  • If a suite contains many similar tests, and the suite itself is well named, test names can be shorter.
  • Name is exactly what you you specify in the test case file without any conversion.
For example, if we have tests related to invalid login in a file invalid_login.robot, these would be OK test case names:
*** Test Cases ***
Empty Password
Empty Username
Empty Username And Password
Invalid Username
Invalid Password
Invalid Username And Password
These names would be somewhat long:
*** Test Cases ***
Login With Empty Password Should Fail
Login With Empty Username Should Fail
Login With Empty Username And Password Should Fail
Login With Invalid Username Should Fail
Login With Invalid Password Should Fail
Login With Invalid Username And Invalid Password Should Fail

Keyword names

  • Also keyword names should be describing and clear.
  • Should explain what the keyword does, not how it does it.
  • Very different abstraction levels (e.g. Input Text or Administrator logs into system).
  • There is no clear guideline should a keyword be fully title cased or should only the first letter is capitalized.
    • Title casing often used when the keyword name is short (e.g. Input Text).
    • Capitalizing just the first letter typically works better with keywords that are like sentences (e.g. Administrator logs into system). These keywords are often also higher level.
Good:
*** Keywords ***
Login With Valid Credentials
Bad:
*** Keywords ***
Input Valid Username And Valid Password And Click Login Button

Naming setup and teardown

  • Try to use name that describes what is done.
    • Possibly use an existing keyword.
  • More abstract names acceptable if a setup or teardown contain unrelated steps.
    • Listing steps in name is duplication and a maintenance problem (e.g. Login to system, add user, activate alarms and check balance).
    • Often better to use something generic (e.g. Initialize system).
  • BuiltIn keyword Run Keywords can work well if keywords implementing lower level steps already exist.
    • Not reusable so best used when certain a setup or teardown scenario is needed only once.
  • Everyone working with these tests should always understand what a setup or teardown does.
Good:
*** Settings ***
Suite Setup     Initialize System
Good (if only used once):
*** Settings ***
Suite Setup     Run Keywords
...             Login To System    AND
...             Add User           AND
...             Activate Alarms    AND
...             Check Balance
Bad:
*** Settings ***
Suite Setup     Login To System, Add User, Activate Alarms And Check Balance

댓글 없음:

댓글 쓰기