mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-25 00:21:28 +02:00
Update src/roadmaps/software-design-architecture/content/100-clean-code-principles/110-keep-tests-independent.md
This commit is contained in:
@@ -4,14 +4,13 @@ Keeping tests independent helps ensures that the tests are reliable, repeatable,
|
||||
|
||||
Here are some ways to keep tests independent in system architecture:
|
||||
|
||||
1. Use dependency injection to decouple the test code from the application code. This allows the tests to be run without the need to instantiate the application objects directly.
|
||||
2. Use mocks or stubs to isolate the test from external dependencies such as databases, APIs, or other services.
|
||||
3. Use test data that is self-contained and does not rely on external data or state.
|
||||
4. Use a test framework that supports running tests in parallel, so that the tests can be run independently of each other.
|
||||
5. Use test-driven development (TDD), which involves writing tests before writing the application code. This ensures that the tests are independent and that the code is written with testability in mind.
|
||||
6. Avoid global state and shared mutable state as it may cause unexpected results.
|
||||
- Use dependency injection to decouple the test code from the application code. This allows the tests to be run without the need to instantiate the application objects directly.
|
||||
- Use mocks or stubs to isolate the test from external dependencies such as databases, APIs, or other services.
|
||||
- Use test data that is self-contained and does not rely on external data or state.
|
||||
- Use a test framework that supports running tests in parallel, so that the tests can be run independently of each other.
|
||||
- Use test-driven development (TDD), which involves writing tests before writing the application code. This ensures that the tests are independent and that the code is written with testability in mind.
|
||||
- Avoid global state and shared mutable state as it may cause unexpected results.
|
||||
|
||||
By following these best practices, the system architecture will be more maintainable, testable, and less error-prone, and it will be easier to run and manage the tests.
|
||||
|
||||
Learn more from the following links:
|
||||
|
||||
|
Reference in New Issue
Block a user