-
Notifications
You must be signed in to change notification settings - Fork 41
DevNotes_DevGuide_CodeTesting
Wojciech Potrzebowski edited this page May 26, 2020
·
6 revisions
There are three different ways to perform code testing in SasView depending on what part of functionality we are testing: core, models, GUI
- For sasview core, tests are located in sasview/test
- For 5.x GUI, tests are located in respective folders e.g for Fitting sasview/src/sas/qtgui/Perspectives/Fitting/UnitTesting/
- For sasmodels tests are part of model definition (see https://github.com/SasView/sasmodels/blob/master/doc/guide/plugin.rst#test-your-new-model)
- Unit tests should test one method only. This allows you to easily identify what failed if the test fails.
- Unit tests should not be coupled together, therefore one unit test CANNOT rely on another unit test having completed first.
- Unit tests should use small and simple data sets.
- Tests should be fast, ideally really fast - certainly not more than a few seconds.
- Untestable code is a code-smell, if you can't get the code under test it probably needs refactoring.
- Weight your testing to be destructive rather than demonstrative. Destructive tests are more efficient in finding bugs.
- Use long and descriptive names for testing functions. The reason is testing functions are never called explicitly. square() or even sqr() is ok in running code, but in testing code you would have names such as test_square_of_number_2(),test_square_negative_number(). These function names are displayed when a test fails, and should be as descriptive as possible.
- Attributes of a good test: Fast, Clear, Isolated, Reliable
- Models: Include at least one test for each model and PLEASE make sure that the answer value is correct (i.e. don't blindly use the function return value to set the test results; instead check against the paper or another program).
- Models: Remember to test a model for critical values (e.g. q=0)
- View/Subscribe to the SasView Calendar
- Fortnightly developer's agenda/minutes
- Developer Guides
- Admin Processes and Procedure Notes
- Active Project Pages
- Historical Archive of Obsolete Pages
- Contributor e-Learning Course (free)
- Non Coding contribution needs/projects
- New functionality projects
- DRAFT for acknowledging contributions