<commit_before>Talkilla Automated Tests
========================

The Talkilla repository contains various levels of tests:

* Lint tests
  * These are used to ensure that the code uses the general standards
  defined in the Coding Style of the [Contributing document](../CONTRIBUTING.md)
* Mocha tests
  * These are unit tests to test the Talkilla node.js server
* Front-end tests
  * These are for unit testing the front-end client javascript code, they use the selenium server to run within the browser
* Functional tests
  * These ensure that Talkilla works functionally correctly

Running all Tests
-----------------

To run the tests:

1. Make sure you've installed node and the required modules as per the local development section of the [README.md file](../README.md)

2. Make sure you have:
  * Mac: /Applications/FirefoxNightly.app installed
  * Linux: /usr/bin/firefox-nightly installed, or a Firefox will be downloaded for you.

3. Run the tests:

        $ make test

Lint Tests
----------

To run the lint tests standalone:

        $ make lint

Mocha Tests
-----------

The test files are found in `test/server`

To run the server unit tests standalone:

        $ make mocha

Front-end Tests
---------------

The test files are found in `test/frontend/`

To run the front-end unit tests standalone:

1. First make sure you are running the server in development mode:

        $ make runserver_dev

2. Visit http://localhost:5000/test/frontend/index.html

You can also run the unit tests all together with:

    $ make frontend

Functional Tests
----------------

The test files are found in `test/functional/`

You'll need Python 2.7.X (not Python 3.X) and
[virtualenv](https://pypi.python.org/pypi/virtualenv).

    $ cd /path/to/talkilla

Run the tests, bootstrapping necessary dependencies from the net:

    $ make selenium

To run the tests repeatedly, automatically for 10 runs or until failure:

    $ make selenium-repeat

To run an individual file for 20 runs, or until failure:

    $ REPEAT_TEST=test/functional/test_SingleBrowser.py REPEAT_TIMES=20 make selenium-repeat

To get full debug output from selenium and Firefox, specify FULL_SELENIUM_DEBUG on the command line:

    $ FULL_SELENIUM_DEBUG=1 make selenium

To debug an intermittently failing test, run an individual test for (e.g.) 20
runs with logging, and stop in the Python debugger when it fails.

* just above the decl of the test (test_video_call, in this case),
  add a line with @debug_on()
* ```
$ FULL_SELENIUM_DEBUG=1 REPEAT_TEST="test/functional/test_MultipleBrowsers.py MultipleBrowsersTest.test_video_call" REPEAT_TIMES=20 make selenium-repeat
```
* debug to your heart's content
* remove the @debug_on()

Working With Individual Functional Test Files
---------------------------------------------

Run one test file:

    $ ./bin/run_selenium_test.sh test/functional/test_SingleBrowser.py

Run one test in particular in a file (the quotes are important):

    $ ./bin/run_selenium_test.sh "test/functional/test_MultipleBrowsers.py MultipleBrowsersTest.test_video_call"

Debugging a single test:

    # start selenium and get the right stuff in your $PATH
    $ ./bin/selenium.sh start
    $ source .venv/bin/activate
    (.venv) $

    # If you're on a Mac, be sure you've installed readline in your
    # virtualenv first, using easy_install and NOT using pip:
    (.venv) $ easy_install readline
<commit_msg>More markdown cleanup<commit_after>Talkilla Automated Tests
========================

The Talkilla repository contains various levels of tests:

* Lint tests
  * These are used to ensure that the code uses the general standards
  defined in the Coding Style of the [Contributing document](../CONTRIBUTING.md)
* Mocha tests
  * These are unit tests to test the Talkilla node.js server
* Front-end tests
  * These are for unit testing the front-end client javascript code, they use the selenium server to run within the browser
* Functional tests
  * These ensure that Talkilla works functionally correctly

Running all Tests
-----------------

To run the tests:

1. Make sure you've installed node and the required modules as per the local development section of the [README.md file](../README.md)

2. Make sure you have:
  * Mac: /Applications/FirefoxNightly.app installed
  * Linux: /usr/bin/firefox-nightly installed, or a Firefox will be downloaded for you.

3. Run the tests:

        $ make test

Lint Tests
----------

To run the lint tests standalone:

        $ make lint

Mocha Tests
-----------

The test files are found in `test/server`

To run the server unit tests standalone:

        $ make mocha

Front-end Tests
---------------

The test files are found in `test/frontend/`

To run the front-end unit tests standalone:

1. First make sure you are running the server in development mode:

        $ make runserver_dev

2. Visit http://localhost:5000/test/frontend/index.html

You can also run the unit tests all together with:

    $ make frontend

Functional Tests
----------------

The test files are found in `test/functional/`

You'll need Python 2.7.X (not Python 3.X) and
[virtualenv](https://pypi.python.org/pypi/virtualenv).

    $ cd /path/to/talkilla

Run the tests, bootstrapping necessary dependencies from the net:

    $ make selenium

To run the tests repeatedly, automatically for 10 runs or until failure:

    $ make selenium-repeat

To run an individual file for 20 runs, or until failure:

    $ REPEAT_TEST=test/functional/test_SingleBrowser.py REPEAT_TIMES=20 make selenium-repeat

To get full debug output from selenium and Firefox, specify FULL_SELENIUM_DEBUG on the command line:

    $ FULL_SELENIUM_DEBUG=1 make selenium

To debug an intermittently failing test, run an individual test for (e.g.) 20
runs with logging, and stop in the Python debugger when it fails.

* just above the decl of the test (test_video_call, in this case),
  add a line with @debug_on()
* ```$ FULL_SELENIUM_DEBUG=1 REPEAT_TEST="test/functional/test_MultipleBrowsers.py MultipleBrowsersTest.test_video_call" REPEAT_TIMES=20 make selenium-repeat```
* debug to your heart's content
* remove the @debug_on()

Working With Individual Functional Test Files
---------------------------------------------

Run one test file:

    $ ./bin/run_selenium_test.sh test/functional/test_SingleBrowser.py

Run one test in particular in a file (the quotes are important):

    $ ./bin/run_selenium_test.sh "test/functional/test_MultipleBrowsers.py MultipleBrowsersTest.test_video_call"

Debugging a single test:

    # start selenium and get the right stuff in your $PATH
    $ ./bin/selenium.sh start
    $ source .venv/bin/activate
    (.venv) $

    # If you're on a Mac, be sure you've installed readline in your
    # virtualenv first, using easy_install and NOT using pip:
    (.venv) $ easy_install readline

{'fraction_non_alphanumeric': 0.10392271662763466, 'fraction_numerical': 0.00702576112412178, 'mean_word_length': 3.257320872274143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6108451', 'n_tokens_mistral': 2072, 'n_tokens_neox': 1907, 'n_words': 810}