Automotive Software

테스트 케이스 종료 본문

프로그래밍 (Programming)/로봇프레임워크 (Robotframework)

테스트 케이스 종료

AutoSW 2023. 3. 18. 00:20

테스트 케이스의 종료는 케이스 내에 사용된 키워드들 중 하나가 실패하는 경우이거나 의도적으로 실패를 나타내는 경우에 발생된다.

  • 키워드가 실패하는 경우
    • 대부분 케이스 후반부에 Should Be... 키워드를 사용하여 결과 값을 비교하는 경우이다.
My Test Case 1
    ${result}=  Run My Keyword True
    Should be True  ${result}
    Log To Console    I wll be printed out

My Test Case 2
    ${result}=  Run My Keyword False
    Should be True  ${result}
    Log To Console    I will not be printed out

*** Keywords ***
Run My Keyword True
    # Do Something
    [RETURN]   True

Run My Keyword False
    # Do Something
    [RETURN]   False
    
    
[Results]
==============================================================================
My Test Case 1                                                        ..I wll be printed out
My Test Case 1                                                        | PASS |
------------------------------------------------------------------------------
HelloWorld                                                            | PASS |
1 test, 1 passed, 0 failed, 0 unknown
==============================================================================
==============================================================================
My Test Case 2                                                        | FAIL |
'False' should be true.
------------------------------------------------------------------------------
HelloWorld                                                            | FAIL |
1 test, 0 passed, 1 failed, 0 unknown
==============================================================================
  • 의도적으로 실패를 나타내는 경우
    • 예를 들면, 아직 테스트 케이스가 완벽히 구현되지 않았을 경우이다.
    • 보통 Fail 또는 Fatal Error와 같은 키워드를 사용하게 되는데,
      • Fail로 인해 하나의 테스트 케이스가 종료된 경우, 다음 테스트 케이스가 실행되지만
      • Fatal Error로 인해 테스트 케이스가 종료된 경우, 해당 테스트 또는 테스트 슈트 전체가 종료된다
      • 하지만 두 경우 모두 Teardown에 설정된 키워드는 수행된다.
    • 키워드가 실패로 종료하는 경우, 실패에 대한 추가정보를 msg 인자를 통해 추가할 수 있다.
My Test Case 3
    Run Not Implemented Keyword
    
** Keywords ***
Run Not Implemented Keyword
    Fail  msg=This Keyword is not implemented yet


[Result]
==============================================================================
My Test Case 3                                                        | FAIL |
This Keyword is not implemented yet
------------------------------------------------------------------------------
HelloWorld                                                            | FAIL |
1 test, 0 passed, 1 failed, 0 unknown
==============================================================================