[libcxx-commits] [libcxx] Update testing documentation with testing guidelines. (PR #87928)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 11 11:44:11 PDT 2024


================
@@ -180,6 +180,42 @@ The tests of libc++ are stored in libc++'s testing related subdirectories:
   ``libcxx/test/libcxx``. The structure of this directories follows the
   structure of ``libcxx/test/std``.
 
+Principles of testing
+---------------------
+
+Tests are a practical way to validate the correctness of the code. As such, they contain pragmatic trade offs between
+the cost of writing and maintaining the tests and the value they provide. Please consider the following principles when
+writing tests:
+
+- **Consider the next reader**
----------------
ldionne wrote:

Per our live discussion just now, it might make sense to turn this over and first state the values, and then provide a list of recommended practices that derive from those values. For example:

```
1. Consider the next reader
2. Consider the effect of time
3. etc..

>From this, we derive the following set of recommended practices. These practices are not hard rules, they are just recommendations that often make sense:
- Write plain text comments explaining what your test is testing when it's not obvious. For example, when testing multiple edge cases for a function, it's often a good idea to document [bla bla bla]. This relates to considerations (1) and (2).
- Write focused tests that test a single thing. [bla bla bla]. This relates to consideration (N).
- etc..
```

https://github.com/llvm/llvm-project/pull/87928


More information about the libcxx-commits mailing list