> For the complete documentation index, see [llms.txt](https://petozoltan.gitbook.io/simplecode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petozoltan.gitbook.io/simplecode/clean-code/clean-code-outline/unit-tests.md).

# Unit Tests

It is not part of this document, find only some thoughts here.

> Clean Code = Testable Code

### Rules

* Continuously write unit tests
* Maintain unit test - *keep them running*
* TDD - Test Driven Development
* Tests must be clean too - *they will change with the code*
* Tests must obey the test patterns
* F.I.R.S.T. principles

### Benefits

Enforces to write testable code Makes the code flexible - *changes with regression tests*

### Code coverage

* Try to reach higher levels (>90%)
* Do not write tests only for the sake of the code coverage

### Good practices

* Use the default (package) visibility for the sake of the unit testing

Unit Testing briefly:

![](https://2662009507-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1Cc_hcV3kt58baLlJP%2F-M1fWTAgd23ZOK2rnlJu%2F-M1fWXicBtavoUQL8PLz%2Ftest-automation-overview.png?alt=media\&token=25cf834f-237a-4572-8bcb-f470738656ce)
