Unit Testing Flashcards

1
Q

In collab, what does the command:
%%file calc.py
do?

A

The code that you write in a cell is save to the file with name calc.py which is located at the current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When testing a class method should you call it or pass a reference??

A

Reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does setUp and tearDown do?

A

They allow us to define statements that will be executed before and after each test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Are unit test executed in the sequence that they are listed in the scrip?

A

No and that’s why they should be independend from one another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is it possible to run a code snippet before all tests and after all tests? If yes, how?

A

Yes. Use setUpClass and tearDownClass with decorator @classmethod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If you want to test calc.py then what naming should you use for the test file and test methods?

A

file: test_calc.py
class: TestCalc(unittest.TestCase)
function add:
test_add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

High coverage means that the code is well tested?

A

Not always

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Low coverage means that the code is not well tested?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly