Add docs on writing tests.
@@ -177,4 +177,53 @@ class ChaSpider(scrapy.Spider):
## Write tests
-TK TK writing tests
+Our general approach to writing tests is to save a copy of a site's HTML in
+`tests/files` and then use that HTML to verify the behavior of each spider. In
+this way, we avoid needing a network connection to run tests and our tests
+don't break every time a site's content is updated.
+
+Here is the test setup and an example test from the Idph spider:
+
+```python
+import pytest
+
+from tests.utils import file_response
+from documenters_aggregator.spiders.idph import IdphSpider
+
+test_response = file_response('files/idph.html')
+spider = IdphSpider()
+parsed_items = [item for item in spider.parse(test_response) if isinstance(item, dict)]
+
+
+def test_name():
+ assert parsed_items[2]['name'] == 'PAC: Maternal Mortality Review Committee Meeting'
+```
+
+It is also possible to execute a function over every element in the `parsed_items` list. In the following example, the `test_classification` function will be invoked once for each element in `parsed_items` list.
+
+```python
+@pytest.mark.parametrize('item', parsed_items)
+def test_classification(item):
+ assert item['classification'] == 'Not classified'
+```
+
+Parameterized test functions are best used to assert something about every event such as the existence of a field or a value all events will share.
+
+You can read more about parameterized test functions [in the pytest docs](https://docs.pytest.org/en/latest/parametrize.html#pytest-mark-parametrize).
+
+You generally want to verify that a spider:
+
+* Extracts the correct number of events from a page.
+* Extracts the correct values from a single event.
+* Parses any date and time values, combining them as needed.
+
+## Create a Pull Request
+
+If your ready to submit your code to the project, you should create a pull
+request on GitHub. You can do this as early as you would like in order to get
+feedback from others working on the project. In this case, please prefix your
+pull request name with `WIP` so that everyone knows what kind of feedback you
+are looking for.
+
+Additionally, please use the pull request description to explain anything you'd
+like a reviewer to know about the code.
