Tartalomjegyzék

< Code Kata

Python Wasa

Egységtesztek

Feladat 001

Feladat:

triangleTest.py
from triangle import Triangle
import unittest
 
class TestTriangle(unittest.TestCase):
 
    def testCalcAreaNormal(self):
        self.assertEqual(Triangle.calcArea(30, 35), 525.0, 'Az eredmény 525.0 kell legyen')
 
    def testCalcAreaLowLeft(self):
        self.assertEqual(Triangle.calcArea(1, 35), 17.5, 'Az eredmény 17.0 kell legyen')
 
    def testCalcAreaNegative(self):
        area = Triangle.calcArea(-5, 35)
        self.assertEqual(area, -1, 'Az elvárt -1')
 
    def testCalcAreaNegative2(self):
        area = Triangle.calcArea(-8, 1)
        self.assertEqual(area, -1, 'Az elvárt -1')
 
 
if __name__ == "__main__":
    unittest.main()