<commit_before>==============================================================================
How To Test a Django App with Robot Framework
==============================================================================

Basic Setup
-----------

  $ mkdir robot-testing
  $ cd robot-testing
  $ virtualenv .env
  $ source .env/bin/activate


Robot Framework Installation
----------------------------

requirements.txt::

  robotframework
  robotframework-selenium2library

pip install -r requirements.txt


Django Installation
-------------------

  $ pip install django
  $ django-admin.py startproject mysite


First Robot Test
----------------

test.robot::

  *** Variables ***

  ${SERVER}               http://localhost:8000/
  ${BROWSER}              firefox


  *** Settings ***

  Documentation   Django Robot Tests
  Library         Selenium2Library  timeout=10  implicit_wait=0.5
  Suite Setup     Open Browser To Login Page
  Suite Teardown  Close Browser


  *** Keywords ***

  Open Browser To Login Page
    Open Browser  ${SERVER}  ${BROWSER}
    Maximize Browser Window


  *** Test Cases ***

  Scenario: As a visitor I can visit the django default page
    Go To  ${SERVER}
    Wait until page contains element  id=explanation
    Page Should Contain  It worked!
    Page Should Contain  Congratulations on your first Django-powered page.


Start Django
------------

  $ cd mysite
  $ python manage.py runserver


Start Selenium Server
---------------------

  $ java -jar .env/lib/python2.7/site-packages/SeleniumLibrary/lib/selenium-server.jar


Run Robot Tests
---------------

  $ pybot test.robot

Output::

  ==============================================================================
  Test :: Django Robot Tests
  ==============================================================================
  Scenario: As a visitor I can visit the django default page            | PASS |
  ------------------------------------------------------------------------------
  Test :: Django Robot Tests                                            | PASS |
  1 critical test, 1 passed, 0 failed
  1 test total, 1 passed, 0 failed
  ==============================================================================
  Output:  /home/timo/workspace/prounix/robot-testing/output.xml
  Log:     /home/timo/workspace/prounix/robot-testing/log.html
  Report:  /home/timo/workspace/prounix/robot-testing/report.html


Further Reading
---------------

http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.3#creating-test-libraries
<commit_msg>No need to start the selenium server.<commit_after>==============================================================================
How To Test a Django App with Robot Framework
==============================================================================

Basic Setup
-----------

  $ mkdir robot-testing
  $ cd robot-testing
  $ virtualenv .env
  $ source .env/bin/activate


Robot Framework Installation
----------------------------

requirements.txt::

  robotframework
  robotframework-selenium2library

pip install -r requirements.txt


Django Installation
-------------------

  $ pip install django
  $ django-admin.py startproject mysite


First Robot Test
----------------

test.robot::

  *** Variables ***

  ${SERVER}               http://localhost:8000/
  ${BROWSER}              firefox


  *** Settings ***

  Documentation   Django Robot Tests
  Library         Selenium2Library  timeout=10  implicit_wait=0.5
  Suite Setup     Open Browser To Login Page
  Suite Teardown  Close Browser


  *** Keywords ***

  Open Browser To Login Page
    Open Browser  ${SERVER}  ${BROWSER}
    Maximize Browser Window


  *** Test Cases ***

  Scenario: As a visitor I can visit the django default page
    Go To  ${SERVER}
    Wait until page contains element  id=explanation
    Page Should Contain  It worked!
    Page Should Contain  Congratulations on your first Django-powered page.


Start Django
------------

  $ cd mysite
  $ python manage.py runserver


Run Robot Tests
---------------

  $ pybot test.robot

Output::

  ==============================================================================
  Test :: Django Robot Tests
  ==============================================================================
  Scenario: As a visitor I can visit the django default page            | PASS |
  ------------------------------------------------------------------------------
  Test :: Django Robot Tests                                            | PASS |
  1 critical test, 1 passed, 0 failed
  1 test total, 1 passed, 0 failed
  ==============================================================================
  Output:  /home/timo/workspace/prounix/robot-testing/output.xml
  Log:     /home/timo/workspace/prounix/robot-testing/log.html
  Report:  /home/timo/workspace/prounix/robot-testing/report.html


Further Reading
---------------

http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.3#creating-test-libraries

{'fraction_non_alphanumeric': 0.2949226497421658, 'fraction_numerical': 0.007933359777865925, 'mean_word_length': 2.4731404958677685, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3766132', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1199, 'n_words': 358}