Changes for page Tips and Tricks

Last modified by chrisby on 2024/04/01 13:11

From version 1.30
edited by chrisby
on 2024/04/01 12:54
Change comment: There is no comment for this version
To version 1.32
edited by chrisby
on 2024/04/01 12:56
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,6 +1,6 @@
1 1  Here are a few general guideline that help to write better test code as well as influencing the design of the production code.
2 2  
3 -* **Frequent Execution**: Run tests frequently, ideally before every commit, for optimal quality assurance. In particular, run all relevant tests before pushing code or creating a pull/merge request. 'Continuous integration' practices are helpful for enforcing testing of code uploaded by other developers.
3 +* **Frequent Execution**: Run tests frequently, ideally before every commit, for optimal quality assurance. In particular, run all relevant tests before pushing code or creating a pull/merge request. [[Continuous Integration>>doc:Software Engineering.Agile.Extreme Programming.Continuous Integration.WebHome]] practices are helpful for enforcing testing of code uploaded by other developers.
4 4  * Use **functional programming** for data processing tasks because it is less prone to errors and side effects.
5 5  * It's common to create **test users and test data** to facilitate the testing process.
6 6  * Don't reinvent the wheel and **use existing test libraries**. There are proven solutions that minimize the effort of creating tests.
... ... @@ -12,12 +12,12 @@
12 12  * Use additional **simple high-level checks**. For example, when working with a collection, checking the number of items before examining an item from the collection in detail is a good indicator of unexpected or missing items.
13 13  * **More is better.** When in doubt, it is better to write one test too many than one test too few. Possible duplication is a lesser evil than not testing at all.
14 14  * **Keep test resources close to the tests** to make their use easy to understand. Test resources should be placed in the same location as the test if the resource is only needed by that test.
15 -* **Avoid threads**
15 +* **Avoid threads in tests**
16 16  ** Concurrent programming is prone to introducing errors and very difficult to test and debug properly.
17 17  ** If threads are necessary, keep the amount of asynchronous code to a minimum.
18 18  ** Separate synchronous and asynchronous logic to test them separately.
19 19  ** Prefer thread termination conditions over fixed wait times, as this usually increases test performance dramatically.
20 -* **Avoid files**
20 +* **Avoid files in tests**
21 21  ** I/O is slow increasing the test time unnecessarily.
22 22  ** Temporary files may persist because you forgot to delete them or put them in folders where they will never be found. At the very least, be sure to delete files at the very beginning of the test to ensure their absence. Deleting files at the end of a test is prone to errors because if the test fails/aborts, those files may persist and affect subsequent tests.
23 23  ** Prefer data streams over files for testing.