import sys table_template = ''' | ID | Test Case Name | Procedure | Expected Output | Screen Dump | Result | |----|----------------|-----------|-----------------|-------------|--------| {{{rows}}} '''.strip() row_template=''' | 1 | 2 | 3 | 4 | 5 | 6 | '''.strip() cases = [ { 'test_case_name':"Display all employees in the system", 'procedure':''' 1. Start program. 2. input 1 for display all employee '''.strip(), 'expected_output':" All employees' information including their employee ID, name, salary and department should be displayed", 'screen_dump':"![](./screenshots/test1.png)", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Add an employee with name "Pika Chiu, salary 15000 and wortks in IT department into the system''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input 'Pika Chiu' for employee's name Input "15000" for salary 3. Input "IT" for IT department '''.strip(), 'expected_output':'''A success message "Employee Added Successfully" should be displayed''', 'screen_dump':"![](./screenshots/test2.png)", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Remove an employee with valid employee id''', 'procedure':''' 1. In the employee management system menu, input '3' to Remove an employee 2. Input 'IVE00006' for employee's id '''.strip(), 'expected_output':'''A success message "Employee Removed Successfully" should be displayed''', 'screen_dump':"![](./screenshots/test3.png)", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Update an employee with valid employee id''', 'procedure':''' 1. In the employee management system menu, input '4' to Update an employee 2. Input 'IVE00005' for employee's id 3. Input '99999' for employee's salary '''.strip(), 'expected_output':'''A success message "Employee Updated Successfully" should be displayed''', 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Display company statistics''', 'procedure':''' 1. In the employee management system menu, input '5' to Update an employee '''.strip(), 'expected_output':''' 1. a list of all employee information listed 2. total number of staff listed 3. staff with highest salary listed 4. staff with lowest salary listed 5. average salary listed ''', 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''exiting system''', 'procedure':''' 1. In the employee management system menu, input "ENTER"(enter key) to exit system '''.strip(), 'expected_output':''' 1. system exit ''', 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''main menu invalid input handling''', 'procedure':''' 1. In the employee management system menu, input "~" to main menu '''.strip(), 'expected_output':''' 1. screen showing "input digit contains non-int value, accepted values are 1,2,3,4,5" alert to user ''', 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''main menu invalid input handling''', 'procedure':''' 1. In the employee management system menu, input "a" to main menu '''.strip(), 'expected_output':''' 1. screen showing "input digit contains non-int value, accepted values are 1,2,3,4,5" alert to user ''', 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Add an employee (invalid employee name)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input 'a1' for employee's name (this is invalid name) 3. Input '123' for employee's name (this is invalid name) 4. Input '4a' for employee's name (this is valid name) 5. Input 'apple' for employee's name (this is valid name) 6. Input "99999" for salary 7. Input "IT" for IT department '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the employee name should not contain digit" alert to user 2. keep asking "Please input employee's name, Enter to return:" until valid name get 3. after getting apple as name, get back to normal employee adding flow ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Add an employee (invalid employee salary)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input 'apple' for employee's name (this is valid name) 3. Input "aaaaa" for salary (invalid input as contains text) 4. Input "11111" for salary (valid input) 5. Input "IT" for IT department '''.strip(), 'expected_output':''' 1. showing "ERROR: Employee's salary contains non digit value" alert to user 2. keep asking "Please input employee's salary, Enter to return:" until valid salary get 3. after getting valid salary, get back to normal employee adding flow ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Add an employee (invalid employee department)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input 'apple' for employee's name (this is valid name) 3. Input "11111" for salary (valid input) 4. Input "Marketing" (invalid input) 5. Input "IT" (valid input) '''.strip(), 'expected_output':''' 1. showing "ERROR: Not a valid department, the valid options are HR, IT, Admin, Finance" alert to user 2. keep asking "Please input employee's department, Enter to return:" until valid department get 3. after getting valid department, show "***** Employee Added Successfully" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Remove an employee (invalid employee id, not existing)''', 'procedure':''' 1. In the employee management system menu, input '3' to remove an employee 2. Input 'IVE00007' for employee's id (this is invalid id, not exist) 2. Input "IVE00006" for employee's id (valid input, existing id) '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the input id not found" alert to user 2. keep asking "Please input employee's id, Enter to return:" until valid id get 3. after getting valid id, show "***** Employee Removed Successfully" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Remove an employee (invalid employee id, invalid format)''', 'procedure':''' 1. In the employee management system menu, input '3' to remove an employee 2. Input 'III00007' for employee's id (this is invalid id, not exist) 2. Input "IVE00006" for employee's id (valid input, existing id) '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the input id not found" alert to user 2. keep asking "Please input employee's id, Enter to return:" until valid id get 3. after getting valid id, show "***** Employee Removed Successfully" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Remove an employee (invalid employee id, invalid format)''', 'procedure':''' 1. In the employee management system menu, input '3' to remove an employee 2. Input 'a' for employee's id (this is invalid id) 2. Input "IVE00006" for employee's id (valid input, existing id) '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the input id not found" alert to user 2. keep asking "Please input employee's id, Enter to return:" until valid id get 3. after getting valid id, show "***** Employee Removed Successfully" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Remove an employee (invalid employee id, invalid format)''', 'procedure':''' 1. In the employee management system menu, input '3' to remove an employee 2. Input '11111111' for employee's id (this is invalid id) 3. Input "IVE00006" for employee's id (valid input, existing id) '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the input id not found" alert to user 2. keep asking "Please input employee's id, Enter to return:" until valid id get 3. after getting valid id, show "***** Employee Removed Successfully" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Update an employee (invalid employee id, invalid format)''', 'procedure':''' 1. In the employee management system menu, input '4' to update an employee 2. Input '1' for employee's id (this is invalid id) 3. Input "IVE00006" for employee's id (valid input, existing id) 4. Input "11111" for employee's id (valid input) '''.strip(), 'expected_output':''' 1. showing "ERROR: sorry but the input id not found" alert to user 2. keep asking "Please input employee's id, Enter to return:" until valid id get 3. after getting valid id, get back to normal update employee flow ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''Update an employee (invalid salary)''', 'procedure':''' 1. In the employee management system menu, input '4' to update an employee 2. Input "IVE00006" for employee's id (valid employee id, existing id) 3. Input "a" for salary (invalid input, salary cannot be non integer value) 4. Input "$" for salary (invalid input, salary cannot be non integer value) 5. Input "111" for salary (value input, integer value only) '''.strip(), 'expected_output':''' 1. showing "ERROR: Employee's salary contains non digit value" alert to user 2. keep asking "Please input employee's salary, Enter to return:" until valid salary get 3. after getting valid salary, show "***** Employee Updated Successfully" to user ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''display highest salary''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '2' to add an employee 3. Input "highest_employee" for name (valid employee name) 4. Input "9999999" for salary (valid highest salary) 5. Input "IT" for department (valid department) 6. Input "5" to check the highest salary got updated '''.strip(), 'expected_output':''' 1. showing "highest_employee" in staff name field with highest salary ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''display lowest salary''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '2' to add an employee 3. Input "lowest_employee" for name (valid employee name) 4. Input "10" for salary (valid lowest salary) 5. Input "IT" for department (valid department) 6. Input "5" to check the lowest salary got updated '''.strip(), 'expected_output':''' 1. showing "lowest_employee" in staff name field with lowest salary ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update statistics after adding user''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '2' to add an employee 3. Input "new_user" for name (valid employee name) 4. Input "10" for salary (valid high salary) 5. Input "IT" for department (valid department) 6. Input "5" to check the lowest salary got updated '''.strip(), 'expected_output':''' 1. number of staff = "6" + "1" = "7" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update statistics after remove user''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '3' to remove an employee 3. Input "IVE00006" for id (valid employee id) '''.strip(), 'expected_output':''' 1. number of staff = "6" - "1" = "5" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update average after adding user''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '2' to add an employee 3. Input "new_user" for name (valid employee name) 4. Input "10" for salary (valid high salary) 5. Input "IT" for department (valid department) 6. Input "5" to check the average salary got updated '''.strip(), 'expected_output':''' 1. average salary changed from $19814.78 to $16,985.53 (average of "7" employee) ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update average after remove user''', 'procedure':''' 1. In the employee management system menu, input '5' get current snap of employee table 2. In the employee management system menu, input '3' to add an employee 3. Input "IVE00001" for id (valid employee id) 4. Input "5" to check the average salary got updated '''.strip(), 'expected_output':''' 1. average salary changed from $19814.78 to $15135.64 (average of "5" employee) ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''add employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input "ENTER"(one key) for name (cancelling the add flow) '''.strip(), 'expected_output':''' 1. showing "***** Employee Add cancelled" 2. back to the main menu ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''add employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input "apple" for name (valid name) 3. Input "ENTER"(one key) for name (cancelling the add flow) '''.strip(), 'expected_output':''' 1. showing "Please input employee's name, Enter to return:" 2. after receiving valid name, showing "Please input employee's salary, Enter to return:" 3. after pressing "ENTER"(one key), showing "***** Employee Add cancelled" 4. back to the main menu ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''add employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '2' to add an employee 2. Input "apple" for name (valid name) 3. Input "100" for salary (valid salary) 4. Input "ENTER"(one key) for department (cancelling the add flow) '''.strip(), 'expected_output':''' 1. showing "Please input employee's name, Enter to return:" 2. after receiving valid name, showing "Please input employee's salary, Enter to return:" 3. after receiving valid salary, showing "Please input employee's department, Enter to return:" 4. after pressing "ENTER"(one key), showing "***** Employee Add cancelled" 5. back to the main menu ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''remove employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '3' to remove an employee 2. Input "ENTER"(one key) for id (cancelling the remove flow) '''.strip(), 'expected_output':''' 1. showing "***** Employee remove cancelled" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '4' to update an employee 2. Input "ENTER"(one key) for id (cancelling the update flow) '''.strip(), 'expected_output':''' 1. showing "***** Employee update cancelled" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, { 'test_case_name':'''update employee (cancelling)''', 'procedure':''' 1. In the employee management system menu, input '4' to update an employee 2. Input "IVE00006" for name (valid name) 3. Input "ENTER"(one key) for salary (cancelling the update flow) '''.strip(), 'expected_output':''' 1. showing "Please input employee's id, Enter to return:" 1. showing "Please input employee's salary, Enter to return:" 1. after pressing "ENTER"(one key), 1. showing "***** Employee update cancelled" ''', 'screen_dump':"", 'result':"Pass/ ~~Fail~~" }, ] i = 0 with open('test_case_table.md','a+') as o: o.truncate(0) o.write(table_template.replace('{{{rows}}}', '\n'.join(map(lambda x: row_template .replace(' 1 ',str(cases.index(x)+1)) .replace(' 2 ',x['test_case_name']) .replace(' 3 ',x['procedure'].replace('\n','
')) .replace(' 4 ',x['expected_output'].replace('\n','
')) .replace(' 5 ',f''' ![](./screenshots/test{str(cases.index(x)+1)}.png) '''.replace('\n','
')) .replace(' 6 ',x['result']) ,cases)))) # D:\\\\_workspace\\daniel_jo_assignment_student\\screenshots\\test{str(cases.index(x)+1)}.png