Update src/roadmaps/software-design-architecture/content/100-clean-code-principles/110-keep-tests-independent.md

content/software-design-and-architecture
Kamran Ahmed 2 years ago committed by GitHub
parent 8afa03cabf
commit 33d62a96da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/roadmaps/software-design-architecture/content/100-clean-code-principles/110-keep-tests-independent.md

@ -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:

Loading…
Cancel
Save