Difference between revisions of "Unit tests"
Poppy Linden (talk | contribs) |
Poppy Linden (talk | contribs) |
||
Line 1: | Line 1: | ||
= | == Why unit test? == | ||
To reduce the amount of risk associated with refactoring legacy code, and to prove the functionality and interface of new code, use unit tests. | |||
Unit tests | In an environment where the code base is highly interdependent, rapidly changing, and expected to provide consistent functionality across years of use, unit tests are one of the few reliable and scalable ways to ensure the code continues to function across time and platforms. | ||
* Confidence when changing a | |||
Unit tests facilitate and provide: | |||
* Confidence when changing a component that the end behavior is consistent or changes are detected and addressed appropriately. | |||
* A wide variety of code examples for using our classes and functions. | * A wide variety of code examples for using our classes and functions. | ||
* Confidence that the code continues to function across third party library, system library, or system image upgrades. | * Confidence that the code continues to function across third party library, system library, or system image upgrades. | ||
== Our | |||
== Our Frameworks == | |||
We have several types of unit tests, each with their own mechanisms. | |||
* Project-level C++ unit tests | |||
* System-level C++ unit tests | |||
* System-level python unit tests | |||
* (more?) | |||
Details on how to run, write, and build each are as follows. | |||
=== Project-level C++ unit tests === | |||
Please see [[How to add unit tests to indra code]] | |||
=== System-level C++ unit tests === | |||
This method of unit testing is deprecated. Please migrate any tests you have in indra/test/ using the project-level C++ test method. If you can't do that, consider making the test into an integration test. | |||
We have a set of tests located in indra/test which are built and run automatically as the tests_ok target in the cmake build. | We have a set of tests located in indra/test which are built and run automatically as the tests_ok target in the cmake build. | ||
The test framework is currently only set up to test the library functionality. | The test framework is currently only set up to test the library functionality. | ||
Line 12: | Line 30: | ||
There are special linden enhancements to the tut framework available in indra/test/lltut.h. | There are special linden enhancements to the tut framework available in indra/test/lltut.h. | ||
== When to write | === System-level python unit tests === | ||
These are started by indra/test/test.py. | |||
== When to write unit tests == | |||
Write tests under any or all of these conditions: | Write tests under any or all of these conditions: | ||
* After writing your functionality declaration but before implementation. At this point, all tests will fail, and you know you are done when all tests pass. | * After writing your functionality declaration but before implementation. At this point, all tests will fail, and you know you are done when all tests pass. | ||
* After you believe a class or library is complete. This is a good time to explore the edge cases. | * After you believe a class or library is complete. This is a good time to explore the edge cases. | ||
* When a bug has been reported, and you need to make the smallest possible piece of code which exposes the bug. | * When a bug has been reported, and you need to make the smallest possible piece of code which exposes the bug. | ||
Thanks for testing! | |||
[[Category:Automated Testing]] | [[Category:Automated Testing]] |
Revision as of 17:50, 7 May 2009
Why unit test?
To reduce the amount of risk associated with refactoring legacy code, and to prove the functionality and interface of new code, use unit tests.
In an environment where the code base is highly interdependent, rapidly changing, and expected to provide consistent functionality across years of use, unit tests are one of the few reliable and scalable ways to ensure the code continues to function across time and platforms.
Unit tests facilitate and provide:
- Confidence when changing a component that the end behavior is consistent or changes are detected and addressed appropriately.
- A wide variety of code examples for using our classes and functions.
- Confidence that the code continues to function across third party library, system library, or system image upgrades.
Our Frameworks
We have several types of unit tests, each with their own mechanisms.
- Project-level C++ unit tests
- System-level C++ unit tests
- System-level python unit tests
- (more?)
Details on how to run, write, and build each are as follows.
Project-level C++ unit tests
Please see How to add unit tests to indra code
System-level C++ unit tests
This method of unit testing is deprecated. Please migrate any tests you have in indra/test/ using the project-level C++ test method. If you can't do that, consider making the test into an integration test.
We have a set of tests located in indra/test which are built and run automatically as the tests_ok target in the cmake build. The test framework is currently only set up to test the library functionality. We use the TUT Framework since it requires no runtime library, and was incredibly simple to integrate. There are special linden enhancements to the tut framework available in indra/test/lltut.h.
System-level python unit tests
These are started by indra/test/test.py.
When to write unit tests
Write tests under any or all of these conditions:
- After writing your functionality declaration but before implementation. At this point, all tests will fail, and you know you are done when all tests pass.
- After you believe a class or library is complete. This is a good time to explore the edge cases.
- When a bug has been reported, and you need to make the smallest possible piece of code which exposes the bug.
Thanks for testing!