<commit_before>Unit-Testing Googkit
====================


System Requirements
-------------------
`coverage` is required for measuring test coverage:

	$ easy_install coverage

If you are using python 3.2 or ealier, you should install [mock](http://www.voidspace.org.uk/python/mock/) module:

	$ easy_install -U mock


Running Unit Tests
------------------
* Running a specified unit test:

		(in /usr/local/googkit)
		$ python -m {test_module_name}


* Running all unit tests:

		(in /usr/local/googkit)
		$ python -m unittest discover

	If you want to run unit tests with python 3.x:

	 	$ python3 -m unittest discover


Measuring test coverage
-----------------------
1. Run all unit tests with `coverage`

		(in /usr/local/googkit)
		$ coverage run -m unittest discover


2. Display report

	* on the terminal:

		$ coverage report


	* on web browser (you can see detailed information):

		$ coverage html
		(then open ./coverage-html/index.html in your browser)


Adding Test Case
----------------
Add a test file to `test/`.
Following template may be useful:

```python
# Run the following command to test:
#
#     (in /usr/local/googkit)
#     $ python -m {test_module_name}
#
# See also: http://docs.python.org/3.3/library/unittest.html#command-line-interface
#
# We cannot use unittest.mock on python 2.x!<commit_msg>Update test/README<commit_after>Unit-Testing Googkit
====================


System Requirements
-------------------
`coverage` is required for measuring test coverage:

	$ easy_install coverage

If you are using python 3.2 or ealier, you should install [mock](http://www.voidspace.org.uk/python/mock/) module:

	$ easy_install -U mock


Running Unit Tests
------------------
* Running a specified unit test:

		(in /usr/local/googkit)
		$ python -m {test_module_name}


* Running all unit tests:

		(in /usr/local/googkit)
		$ python -m unittest discover

	If you want to run unit tests with python 3.x:

	 	$ python3 -m unittest discover


Measuring test coverage
-----------------------
1. Run all unit tests with `coverage`

		(in /usr/local/googkit)
		$ coverage run -m unittest discover


2. Display report

	* on the terminal:

		$ coverage report


	* on the web browser (you can see detailed information):

		$ coverage html
		(then open ./coverage-html/index.html in your browser)


Adding Test Case
----------------
Add a test file to `test/`.
Following template may be useful:

```python
# Run the following command to test:
#
#     (in /usr/local/googkit)
#     $ python -m {test_module_name}
#
# See also: http://docs.python.org/3.3/library/unittest.html#command-line-interface
#
# We cannot use unittest.mock on python 2.x!
{'fraction_non_alphanumeric': 0.16172607879924952, 'fraction_numerical': 0.00675422138836773, 'mean_word_length': 2.7338935574229692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7421079', 'n_tokens_mistral': 876, 'n_tokens_neox': 795, 'n_words': 289}