mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-03-12 17:51:53 +08:00
Revise section on fast and independent tests (#9534)
Added principles for fast and independent tests to enhance understanding of testing best practices.
This commit is contained in:
committed by
GitHub
parent
480b1bb791
commit
a4edce4145
@@ -1 +1,27 @@
|
||||
# Tests should be fast and independent
|
||||
# Tests Should Be Fast and Independent
|
||||
|
||||
Fast and independent tests are a cornerstone of reliable and maintainable software. They enable developers to run tests frequently, get quick feedback, and trust the results. When tests are slow or tightly coupled to each other or external systems, they become a bottleneck and reduce confidence in the codebase.
|
||||
|
||||
Well-designed tests focus on validating behavior in isolation and execute quickly enough to be run as part of everyday development.
|
||||
|
||||
Some of the key principles of fast and independent tests include:
|
||||
|
||||
* Speed: Tests should execute quickly so they can be run frequently during development.
|
||||
* Independence: Each test should run in isolation and not depend on the outcome or state of other tests.
|
||||
* Determinism: Tests should produce the same result every time they are run.
|
||||
* Isolation: External dependencies (databases, APIs, file systems, time) should be mocked or stubbed.
|
||||
* Single Responsibility: Each test should verify one behavior or scenario.
|
||||
* Easy Setup and Teardown: Tests should have minimal and clear setup logic.
|
||||
* Reliability: Tests should fail only when the code under test is broken, not due to environment issues.
|
||||
* Automation Friendly: Tests should be easy to run in CI/CD pipelines without special configuration.
|
||||
* Maintainability: Tests should be easy to read, understand, and update as the code evolves.
|
||||
* Feedback-Oriented: Test failures should provide clear and actionable feedback.
|
||||
|
||||
Fast and independent tests improve developer productivity, encourage refactoring, and act as living documentation for the system’s behavior.
|
||||
|
||||
Learn more from the following links:
|
||||
|
||||
* [@article@Unit Testing Best Practices](https://martinfowler.com/articles/practical-test-pyramid.html)
|
||||
* [@article@Test Pyramid Explained](https://martinfowler.com/bliki/TestPyramid.html)
|
||||
* [@article@Writing Reliable Tests](https://testing.googleblog.com/2014/05/testing-on-toilet-how-much.html)
|
||||
* [@feed@Explore top posts about Testing](https://app.daily.dev/tags/testing?ref=roadmapsh)
|
||||
|
||||
Reference in New Issue
Block a user