summaryrefslogtreecommitdiff
path: root/CONTRIBUTING.rst
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2018-11-08 14:29:34 +0000
committerJürg Billeter <j@bitron.ch>2018-11-15 19:48:12 +0000
commit082b381184cd3d97aa94ce637992cf088fae5c15 (patch)
tree29db447de4248a93e71ac9895dc6d2d487e9b03a /CONTRIBUTING.rst
parent327b19dde3c9c52c9a1d4dc6feb085467ede14ac (diff)
downloadbuildstream-082b381184cd3d97aa94ce637992cf088fae5c15.tar.gz
contributing: add guidance on unit tests
Decrease uncertainty around whether unit tests are welcome in the project or not.
Diffstat (limited to 'CONTRIBUTING.rst')
-rw-r--r--CONTRIBUTING.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index dcd21e07d..da8bcab77 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1547,6 +1547,24 @@ Tests that run a sandbox should be decorated with::
and use the integration cli helper.
+You should first aim to write tests that exercise your changes from the cli.
+This is so that the testing is end-to-end, and the changes are guaranteed to
+work for the end-user. The cli is considered stable, and so tests written in
+terms of it are unlikely to require updating as the internals of the software
+change over time.
+
+It may be impractical to sufficiently examine some changes this way. For
+example, the number of cases to test and the running time of each test may be
+too high. It may also be difficult to contrive circumstances to cover every
+line of the change. If this is the case, next you can consider also writing
+unit tests that work more directly on the changes.
+
+It is important to write unit tests in such a way that they do not break due to
+changes unrelated to what they are meant to test. For example, if the test
+relies on a lot of BuildStream internals, a large refactoring will likely
+require the test to be rewritten. Pure functions that only rely on the Python
+Standard Library are excellent candidates for unit testing.
+
Measuring performance
---------------------