在python中,我们如何为我们的类编写测试用例?例如:
class Employee(object):
num_employees = 0
# numEmployess is incremented each time an employee is constructed
def __init__(self, salary=0.0, firstName="", lastName="", ssID="", DOB=datetime.fromordinal(1), startDate=datetime.today()): #Employee attributes
self.salary=salary
self.firstName = firstName
self.lastName = lastName
self.ssID = ssID
self.DOB = DOB
self.startDate = startDate
Employee.num_employees += 1 #keep this
def __str__(self): #returns the attributes of employee for print
return str(self.salary) + ', ' + self.firstName + ' ' + self.lastName + ', ' + self.ssID + ', ' + str(self.DOB) + ', ' + str(self.startDate)
我知道有一种叫做单元测试的东西。但我完全不确定它是如何工作的。在网上找不到我理解的很好的解释。