Testing
Advertisements
Related Guides
Unit Testing
| |
A test stub is quickly developed code that is used as a placeholder so that other sections of code can be unit tested. Test stubs typically return a hardcoded response that is in a valid format but completely static. They are useful for unit testing when dependencies aren't developed yet, aren't available, are unreliable, slow or difficult to setup with required test data. The following are illustrative examples.
Data AccessA stub for a data access object that isn't developed yet. Returns hardcoded values.IntegrationA developer uses a stub to simulate integration with systems that she can't connect to on her local environment.Test DataA developer uses a test stub to simulate a wide variety of responses from systems. For example, a developer may simulate rare response codes for a banking transaction that are difficult to arrange in development environments.
User InterfaceA developer initially populates a web page with a hello world message to test that a redirect is working.StabilityA module does frequent transactions with an external system that is often down. A developer implements a test stub to replace the calls to the system to increase the reliability of unit tests.SpeedA software function involves algorithms that are computationally complex. A developer implements a test stub to temporarily replace such algorithms to speed their unit testing.|
Type | Unit TestingCoding | Definition | Quickly developed code that is used as a placeholder to facilitate unit testing. | Value | Unit testing when dependencies aren't ready, are unstable, slow or difficult to setup with required data. | Related Concepts | TestingUnit TestingTest AutomationTest FixtureTest HarnessTest DriversMock Object |
Testing
This is the complete list of articles we have written about testing.
If you enjoyed this page, please consider bookmarking Simplicable.
© 2010-2023 Simplicable. All Rights Reserved. Reproduction of materials found on this site, in any form, without explicit permission is prohibited.
View credits & copyrights or citation information for this page.
|