Create unit tests with testr framework
Increase unit test coverage using testr in conjunction with Mock objects and sqlite.
Concentrate on models, utility classes, and other areas that have been tested directly.
Blueprint information
- Status:
- Complete
- Approver:
- Tim Simpson
- Priority:
- Undefined
- Drafter:
- Dan Nguyen
- Direction:
- Approved
- Assignee:
- Dan Nguyen
- Definition:
- Approved
- Series goal:
- Accepted for grizzly
- Implementation:
- Implemented
- Milestone target:
- None
- Started by
- Michael Basnight
- Completed by
- Michael Basnight
Whiteboard
Unit Tests
-------------
Example of testr 'unit tests' structure in reddwarf code base.
Naming of packages and test classes should mirror the src code.
You can use sqlite here too.
TODO(tim.simpson): I disagree. Using sqlite doesn't add to the time it takes to run tests and can sometimes be easier than mocking out every single DB call. I'd disagree even if they weren't, but Nova seems to still be using sqlite: https:/
Any method level unit tests that only talk to mock objects or fakes should live under
--> /reddwarf/
reddwarf
|
reddwarf/
├── __init__.py
├── guestagent
│ ├── __init__.py
│ ├── test_dbaas.py
│ ├── test_pkg.py
│
└── api
├── __init__.py
├── test_versions.py
TODO: need to check with openstack to see how other projects are organized. (They could be different across the board)
Gerrit topic: https:/
Addressed by: https:/
Work in progress for testr unit tests (versions)
Gerrit topic: https:/
Addressed by: https:/
Testr unit tests for versions
Addressed by: https:/
testr unit tests for versions api
TODO(tim.simpson): We already have tests like this by running different groups in the Reddwarf Integration tests. Call them integration or functional but the goals here are identical to what we already have.
(Dan and Juice)
We would like to propose renaming the existing int-tests to func-tests (proboscis).
Work Items
Work items:
Use existing testr framework and mock library introduced in guest-agent tests: TODO
Make use of sqlite and mock objects where necessary: TODO
Consider having separate modules or packages for unit test (using mocks) and functional tests (using sqlite): TODO
Write positive and negative test: TODO
Refactor code where necessary (this might be required if code is too tightly coupled to unit test): TODO