-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram2_UnitTests.py
More file actions
41 lines (32 loc) · 932 Bytes
/
Program2_UnitTests.py
File metadata and controls
41 lines (32 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import unittest
from Program2 import recur_fibo
class testCases(unittest.TestCase):
# After 3 loops, the program should output 2
def testThreeLoop(self):
# arrange
sut = recur_fibo(3)
# act
expected = 2
# assert
self.assertEqual(sut, expected)
# This test will pass because the assertion
# does not expect the output to be equal to 2
def testThreeLoopAlt(self):
# arrange
sut = recur_fibo(3)
# act
expected = 10
# assert
self.assertNotEqual(sut, expected)
# This test will fail because it is expecting
# the wrong output
def testFourLoopFail(self):
# arrange
sut = recur_fibo(4)
# act
expected = 3
# assert
self.assertEqual(sut, expected)
if __name__ == "__main__":
# run the tests
unittest.main()