Unit Theory Flashcards
What is pyunit
Unit testing framework for python
Advocates first testing then coding
Set up test data for a piece of code
Test the test set up
Write the code
Then unit test the code using test set up
Can increase programme productivity
Why use unit tests
Help developers verify that the logic of a piece of code is correct
Re performing unit tests can identify software regressions introduced by changes in the code
May not be suitable for all code
What happens when unit tests fails
For an individual programmer - compilation will fail until unit test passes
For a group programming together - the group build will fail unless all unit tests pass
Continuous integration
Development practice that requires developers to integrate code into a shared repository several times a day
Each check in verified by an automated build allowing teams to detect problems early
Automated builds are inherently associated with unit testing
Pyunit
Runs automatically
Checks results automatically and flags errors
No errors mean all test passed
Tests can be organised into suites of test cases
Quicker than manual testing
Pyunit test case
Piece of code that checks another piece of code works as expected
Testing framework that enables us to quickly develop execute and re execute unit test cases for pythonccode
A known input and expected output
Both input and expected outputs are identified before the test is executed
How many unit test cases
At least two unit test cases
One positive and negative test
Positive test cases
Testing for something that should happen does happen
Negative testing
Testing for something that should not happen does not happen