Skip to content

Commit

Permalink
Adding the process to run acceptance tests to the README
Browse files Browse the repository at this point in the history
Signed-off-by: Emiliemorais <emilie.mo@hotmail.com>
Signed-off-by: Italo Paiva <italosensei@hotmail.com>
  • Loading branch information
italopaiva authored and gabrielssilva committed Apr 12, 2016
1 parent 93e4998 commit feb66e9
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 18 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ sudo: false
python:
- "2.7"

addons:
apt:
packages:
- xvfb
- firefox

env:
global:
- COLAB_SETTINGS=tests/colab_settings.py

install:
- pip install coveralls flake8 behave behave_django
- pip install coveralls flake8 behave behave_django selenium
- pip install .

script:
- python setup.py test
- colab-admin behave
- xvfb-run -a colab-admin behave --format=progress
- flake8 colab

after_success:
Expand Down
100 changes: 100 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,103 @@ Follow the steps below:
.. code-block::
python setup.py test
How to run Acceptance Tests
---------------------------

Follow the steps below to run the acceptance tests. Perharps you may want to run the install commands with 'sudo'.

1- Log in virtual machine:

.. code-block::
vagrant ssh
2- Use colab virtualenv:

.. code-block::
workon colab
3- Install 'behave_django':

.. code-block::
pip install behave_django
4- Update behave to the edge version

.. code-block::
pip install git+https://github.com/behave/behave
5- Install selenium:

.. code-block::
pip install selenium
6- Make sure you have the web browser Firefox installed on your VM. You can simply install it by typing:

CentOS

.. code-block::
yum install firefox
Ubuntu

.. code-block::
apt-get install firefox
7- Make sure that you have the X11 installed on your VM. You can install it by typing:

CentOS

.. code-block::
yum groupinstall x11
Ubuntu

.. code-block::
apt-get install xorg
8- Exit the VM and then enter again using this, to give the VM access to your graphic interface:

.. code-block::
vagrant ssh -- -X
9- Use colab virtualenv:

.. code-block::
workon colab
10- Enter into colab source code directory:

.. code-block::
cd /vagrant
11- Run all the acceptance tests with:

.. code-block::
colab-admin behave
To run a specific feature:

.. code-block::
colab-admin behave /path/to/features/file.feature
12- If you try to run the behave tests and stumble in some errors because of static files (css, js, etc), try running the following to fix it:

.. code-block::
sudo `which colab-admin` collectstatic
1 change: 0 additions & 1 deletion colab/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
'haystack',
'hitcounter',
'taggit',
'behave_django',

# Own apps
'colab',
Expand Down
14 changes: 3 additions & 11 deletions features/environment.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
from selenium import webdriver
from django.conf import settings


def before_all(context):
# Otherwise the ManifestStaticFilesStorage will use hashed names
settings.DEBUG = True

def before_feature(context, feature):
if 'selenium' in feature.tags:
context.driver = webdriver.Firefox()
context.driver.set_window_size(1000, 600)
context.driver.implicitly_wait(5)
else:
context.driver = webdriver.PhantomJS()
context.driver = webdriver.Firefox()
context.driver.set_window_size(1000, 600)
context.driver.implicitly_wait(5)


def after_feature(context, feature):
Expand Down
2 changes: 0 additions & 2 deletions features/steps/user_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ def create_user(context, username, password, status):
user.set_password(password)
user.email = "usertest@colab.com.br"
user.id = 1
user.twitter = "usertestcolab"
user.facebook = "usertestcolab"
user.first_name = "USERtestCoLaB"
user.last_name = "COLAB"
user.needs_update = False
Expand Down
3 changes: 2 additions & 1 deletion features/steps/web_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def step_impl(context, url):

@when(u'I click in "{link}"')
def step_impl(context, link):
context.driver.find_element_by_xpath("//a[contains(., '%s')]" % link).click()
context.driver.find_element_by_xpath("//a[contains(., '%s')]" %
link).click()


@when(u'I click in "{button_value}" button')
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'coveralls>=0.5',
'flake8>=2.3.0',
'mock==1.0.1',
'behave>= 1.2.0',
'selenium>=2.53.1',
'behave>=1.2.0',
'behave_django>=0.2.2',
]

Expand Down

0 comments on commit feb66e9

Please sign in to comment.