Unit Testing Flashcards
In collab, what does the command:
%%file calc.py
do?
The code that you write in a cell is save to the file with name calc.py which is located at the current directory
When testing a class method should you call it or pass a reference??
Reference
What does setUp and tearDown do?
They allow us to define statements that will be executed before and after each test
Are unit test executed in the sequence that they are listed in the scrip?
No and that’s why they should be independend from one another
Is it possible to run a code snippet before all tests and after all tests? If yes, how?
Yes. Use setUpClass and tearDownClass with decorator @classmethod
If you want to test calc.py then what naming should you use for the test file and test methods?
file: test_calc.py
class: TestCalc(unittest.TestCase)
function add:
test_add
High coverage means that the code is well tested?
Not always
Low coverage means that the code is not well tested?
Yes