3.试创建下列问题域的领域模型。 (1)测试工具领域知识:可以添加并运行测试用例,为了方便对测试用例的管理,也可 以先添加测试集合,然后将一到多个测试用例或者测试集合添加。选中一个测试的测试用 例或者测试集合,可以运行测试,并记录下测试结果。 (2)大学领域知识:学校由学院组成,每个学院有一位院长,以及多位教师和学生。每 位教师可以讲多门课,一门课也可以由多位教师同时讲。学生可以选课,并有每学期的成绩 记录。 (3)飞机票预订系统:预订某一航班的机票,包括具体的时间和座位,预订后,顾客必须 在一定的时间内购票,否则预订无效:旅行社和航空售票处均可进行预订服务。
时间: 2023-05-26 20:03:52 浏览: 81
测试用例设计工具.pptx
(1)测试工具领域知识:
class TestTool:
def __init__(self):
self.test_cases = []
self.test_sets = []
self.results = {}
def add_test_case(self, test_case):
self.test_cases.append(test_case)
def add_test_set(self, test_set):
self.test_sets.append(test_set)
def run_test(self, test):
# execute the test and store the result
self.results[test] = result
class TestCase:
def __init__(self, name, description):
self.name = name
self.description = description
def run(self):
# execute the test case and return the result
return result
class TestSet:
def __init__(self, name, description):
self.name = name
self.description = description
self.test_cases = []
def add_test_case(self, test_case):
self.test_cases.append(test_case)
def run(self):
# execute all the test cases in the set and store the results
for test_case in self.test_cases:
self.results[test_case] = test_case.run()
(2)大学领域知识:
class School:
def __init__(self, name):
self.name = name
self.colleges = []
def add_college(self, college):
self.colleges.append(college)
class College:
def __init__(self, name, dean):
self.name = name
self.dean = dean
self.teachers = []
self.students = []
self.courses = []
def add_teacher(self, teacher):
self.teachers.append(teacher)
def add_student(self, student):
self.students.append(student)
def add_course(self, course):
self.courses.append(course)
class Teacher:
def __init__(self, name):
self.name = name
self.courses = []
def add_course(self, course):
self.courses.append(course)
class Student:
def __init__(self, name):
self.name = name
self.grades = {}
def add_grade(self, course, grade):
self.grades[course] = grade
class Course:
def __init__(self, name):
self.name = name
self.teachers = []
self.students = []
def add_teacher(self, teacher):
self.teachers.append(teacher)
def add_student(self, student):
self.students.append(student)
(3)飞机票预订系统:
class Flight:
def __init__(self, number, departure_date, departure_time, arrival_date, arrival_time, origin, destination, seats):
self.number = number
self.departure_date = departure_date
self.departure_time = departure_time
self.arrival_date = arrival_date
self.arrival_time = arrival_time
self.origin = origin
self.destination = destination
self.seats = seats
class Customer:
def __init__(self, name):
self.name = name
self.bookings = []
def book_flight(self, flight, seat, expiration):
booking = Booking(flight, seat, expiration)
self.bookings.append(booking)
class Booking:
def __init__(self, flight, seat, expiration):
self.flight = flight
self.seat = seat
self.expiration = expiration
class BookingService:
def __init__(self):
self.bookings = []
def reserve_flight(self, flight, seat, expiration):
booking = Booking(flight, seat, expiration)
self.bookings.append(booking)
def get_bookings_for_flight(self, flight):
return [booking for booking in self.bookings if booking.flight == flight]
def confirm_booking(self, booking):
self.bookings.remove(booking)
阅读全文