summaryrefslogtreecommitdiff
path: root/testing/README.md
blob: 06e6c4ead9f09bc9d2d4bb754f1eb0e18e832063 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Python testing with `pytest`

This is a very simple outline of this workshop:

- General introduction to testing and Test Driven Development (TDD)

- Start with a very simple example, `gcd`.

- Show how to do the simplest TDD using `pytest`.

- Basic `pytest` features:
  - Testing cases where an exception should be raised
  - Testing floating point numbers with `pytest.approx`
  - Grouping tests in classes.

- Next take a more complex problem:
  - Find all the git repositories recursively inside a given directory.
  - Write tests for this.
  - General approach on how to do this.
  - Use TDD.

- Writing fixtures:
  - Previous example as motivation for this.
  - Creating simple fixtures.
  - Fixture cleanup.
  - Fixture with data.
  - Fixtures using other fixtures.
  - Fixture scope and other ways to use fixtures with `pytest.mark`

- Some pointers on how to write better tests.
  - Link to useful articles.

- Interlude, travis-ci
  - Push code to github
  - Setup travis-ci
  - .travis.yml
  - Run tests.
  - Show updates and PRs.
  - Add badge to README.

- Coverage and improving tests.
  - Look at coverage
  - Show simple reports
  - HTML reports.

- Setup codecov.
  - See how codecov shows the reports and tracks coverage
  - Explore codecov.io

- More on testing with pytest
    - Using tmpdir.
    - Using capsys.
    - Using monkeypatch/mock.