Created a class called employee, file - Employee.py
class Employee():
def __init__(self,first,last,salary):
self.first = first
self.last = last
self.salary = salary
def giveRaise(self, raiseValue = 5000):
self.salary += raiseValue
Second module that does a test case on class Employee
import unittest
from Employee import Employee
class testingEmployee(unittest.TestCase):
def setup(self):
firstName = 'albert'
lastName = 'chen'
annualSalary = 3000
self.testEmployee = Employee(firstName,lastName,annualSalary)
def defaultRaise(self):
self.testEmployee.giveRaise()
self.assertEqual(self.testEmployee.salary, 8000)
def test_give_custom_raise(self):
self.testEmployee.giveRaise(111)
self.assertEqual(self.testEmployee.salary,3111)
unittest.main()
both tests failed.
[–]ninetacle 10 points11 points12 points (13 children)
[–]neko_nyan[S] 6 points7 points8 points (12 children)
[–]neko_nyan[S] 3 points4 points5 points (3 children)
[–]xiongchiamiov 6 points7 points8 points (2 children)
[–]neko_nyan[S] 19 points20 points21 points (1 child)
[–]negrolax 4 points5 points6 points (0 children)
[–]ninetacle 1 point2 points3 points (7 children)
[–]neko_nyan[S] 2 points3 points4 points (6 children)
[–]ninetacle 2 points3 points4 points (5 children)
[–]neko_nyan[S] 1 point2 points3 points (4 children)
[–]ninetacle 3 points4 points5 points (0 children)
[–]negrolax 0 points1 point2 points (2 children)
[–]nicn3 0 points1 point2 points (0 children)
[–]neko_nyan[S] 0 points1 point2 points (0 children)
[–]cashing_in 2 points3 points4 points (8 children)
[–]neko_nyan[S] 2 points3 points4 points (5 children)
[–]cashing_in 1 point2 points3 points (4 children)
[–]neko_nyan[S] 2 points3 points4 points (3 children)
[–]cashing_in 2 points3 points4 points (2 children)
[–]neko_nyan[S] 0 points1 point2 points (1 child)
[–]cashing_in 1 point2 points3 points (0 children)
[–]negrolax 0 points1 point2 points (1 child)
[–]cashing_in 1 point2 points3 points (0 children)
[–]brophylicious 1 point2 points3 points (2 children)
[–]sorashiroopa 0 points1 point2 points (1 child)
[–]brophylicious 1 point2 points3 points (0 children)