티스토리 뷰

카테고리 없음

robotframework

Jacob_baek 2015. 10. 23. 14:33

ATDD(Acceptance Test Driven Development)를 지향하는 test framework

python을 기반으로 만들어졌고 jython(JVM), IronPython(.NET), PyPy 등을 지원한다.

흔히 줄여서 RF라고도 불리운다.


해당 Test Framework는 keyword를 기반으로 동작하게 된다.

1. meaning of keyword driven 

   table-driven testing 혹은 action word based testing이라고도 불리운다.

   키워드나 동작단어를 통해 테스트를 수행하도록 돕는다.

   - https://en.wikipedia.org/wiki/Keyword-driven_testing


2. meaning of data driven

   하나의 keyword를 사용해 다양한 input/output 값을 테스트할수 있는 방법이라 생각하면 된다.


참고사이트

- http://www.ranorex.com/blog/keyword-driven-test-automation-framework


robotframework는 다양한 plugin, 외부 library가 존재한다.

아래 사이트에서 기본적으로 제공되는 library를 확인할 수 있다.

- http://robotframework.org/robotframework/

library의 load는 하단에 Setting Table에 Library라 추가하며 관련된 library name을 입력해주면 된다.


아래 사이트는 기본적으로 제공되는 library 외 에 설치 후 사용 가능한 library에 대한 링크이다.

- https://code.google.com/p/robotframework/wiki/TestLibraries#External_test_libraries

- http://robotframework.org/#test-libraries


install 방법은 아래 링크를 통해 설치하면 된다.

- http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#installation-instructions

간단하게 pip를 통해서도 설치가 가능하다.


install이 완료되면 pybot command를 사용할 수 있게 된다.

pybot : Test execution

      

rebot : post-processing

        Robot Framework report and log generator


다양한 방법의 쉬운 test case 작성이 가능하다.

전반적인 실행에 대한 결과 및 과정을 아래를 통해 확인할 수 있다.


우선 test를 실행하기 위한 file의 구조부터 이해 해야 한다.

총 4가지의 테이블로 구성되어 있다.

*** Settings ***

# 라이브러리를 임포트 하거나 테스트 시작과 끝에 수행할 테스트를 지정할수 있다.

Documentation   test for starfs with nginx
Library     Process
Library     OperatingSystem
# RequsetUrl는 개인적으로 생성하여 추가한 library로 urllib2 module을 이용한 response code check
Library     RequestUrl.py
Suite Setup    Start Nginx
Suite Teardown    Terminate All Processes    kill=True

*** Variables ***

# 해당 테스트 내에서 사용할 수 있는 변수들을 지정할 수 있다.

${PATH}     /usr/local/nginx/

*** Test Cases ***

# 실제 Test가 수행되어지는 영역

Test Allow
    Process Should Be Running
    Send Signal To Process    SIGHUP    nginx
    ${response_code}    do request  http://127.0.0.1
    Should Be Equal As Integers    ${response_code}    200


#*** Comment ***

# Comment 를 추가한 경우 test cases 항목(comment 선언된 다음부터)을 주석처리 한다.

Test Deny

Process Should Be Running

Send Signal To Process    SIGHUP    nginx

${response_code}    do request  http://127.0.0.1

Should Be Equal As Integers    ${response_code}    403


# keywords 는 test cases 및 동일한 keywords 영역에서도 사용가능한 테스트 object를 생성할 수 있다.

*** Keywords ***

Start Nginx

Start Process   ${PATH}/sbin/nginx  stdout=stdout.txt   stderr=stderr.txt   alias=nginx

    Process Should Be Running


※ 참고로 key value 로 작성되는 항목들은 4 spacebar 가 띄워지지 않으면 non-exist library error가 발생됨

※ 테이블 생성시 위와 같이 tab 으로 설정할 수도 있으며 |,

※ 해당 예제는 nginx 를 대상으로 한 test example 이다.


위의 예제를 실행해 본 결과이다.

jacob@desktop:~/test$ pybot acltest.robot
==============================================================================
AclTest :: test for acl in nginx
==============================================================================
Test Allow                                                            | PASS |
------------------------------------------------------------------------------
Test Deny                                                             | PASS |
------------------------------------------------------------------------------
AclTest :: test for acl in nginx                                      | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output:  /home/jacob/test/output.xml
Log:     /home/jacob/test/log.html
Report:  /home/jacob/test/report.html


아래 페이지에서 demo script를 받아 실행해볼수 있다.

- https://bitbucket.org/robotframework/robotdemo/wiki/Home#rst-header-test-cases



Robotframework IDE

test case 작성을 도와주는 IDE

- https://github.com/robotframework/RIDE



jenkins plugin

- https://wiki.jenkins-ci.org/display/JENKINS/Robot+Framework+Plugin


참고사이트

- https://blog.codecentric.de/en/2012/04/robot-framework-tutorial-a-complete-example/

- https://twiki.cern.ch/twiki/bin/view/EMI/RobotFrameworkAdvancedGuide#Test_Data_Tables








댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함