Introduction
- These are high-level guidelines for writing good test cases using Robot Framework.
- How to actually interact with the system under test is out of the scope of this document.
- Robot Framework에서 좋은 테스트 케이스를 작성하는 추상화가 높은 가이드라인입니다.
- 시스템과 연계하는 것 까지는 이 문서에서 설명하지 않습니다.
- Most important guideline is keeping test cases as easy to understand as possible for people familiar with the domain.
- This typically also eases maintenance.
- 가장 중효한 가이드 라인은 테스트 케이스를 이해하기 쉽게 만들어 사람들을 이 부분에 친숙하도록 만드는 것입니다.
- 이해하기 쉽도록 하면 유지보수하기도 쉬워 집니다.
- For more information about this subject, you may want to take a look at these great resources:
- Robot Framework Dos and Don'ts slides that are based on this how-to.
- Writing Maintainable Automated Acceptance Tests article by Dale Emery.
- How to Structure a Scalable And Maintainable Acceptance Test Suite blog post by Andreas Ebbert-Karroum.
- 이 주제로 조금 더 많은 정보는, 아래의 대단한 리소스들에 있습니다:
- Robot Framework에서 할 것, 하지 않을 것 이 내용에 기반한
- 유지보수 쉬운 자동화 인수테스트를 쓰는 법 article by Dale Emery.
- 확장성과 유지보수가 쉬운 인수 테스트 모음을 어떻게 구조화 하는가 blog post by Andreas Ebbert-Karroum.
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
orAdministrator 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.
- Title casing often used when the keyword name is short (e.g.
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
).
- Listing steps in name is duplication and a maintenance problem (e.g.
- 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
댓글 없음:
댓글 쓰기