Spring22-Exercise3-UnitTesting
Spring22-Exercise3-UnitTesting
Unit Testing
Gregory Gay
DIT635 - February 11, 2022
Enter… The Planning System
Code: https://bit.ly/3B39YYI
Activity: https://bit.ly/32XM308
3
Code: https://bit.ly/3B39YYI
Develop a Test Plan Activity: https://bit.ly/32XM308
4
Food for Thought Code: https://bit.ly/3B39YYI
Activity: https://bit.ly/32XM308
5
Code: https://bit.ly/3B39YYI
Develop Unit Tests Activity: https://bit.ly/32XM308
6
Can you expose the faults?
7
Can you expose the faults?
1: getMeeting and removeMeeting perform no error
checking on dates.
public Meeting getMeeting(int month, int day, int index){
return occupied.get(month).get(day).get(index);
}
8
Can you expose the faults?
2: Calendar has a 13th month.
public Calendar(){
occupied = new ArrayList<ArrayList<ArrayList<Meeting>>>();
for(int i=0;i<=13;i++){
// Initialize month
occupied.add(new ArrayList<ArrayList<Meeting>>());
for(int j=0;j<32;j++){
// Initialize days
occupied.get(i).add(new ArrayList<Meeting>());
}
}
}
9
Can you expose the faults?
3: November has 30 days.
Oh - and we just added a meeting to a day with a date that
does not match that date.
occupied.get(11).get(30).add(new Meeting(11,31,"Day does not
exist"));
10
Can you expose the faults?
4: Used a >= in checking for illegal times. December
no longer exists.
if(mMonth < 1 || mMonth >= 12){
throw new TimeConflictException("Month does not
exist.");
}
11
Can you expose the faults?
5: We should be able to start and end a meeting in the
same hour.
if(mStart >= mEnd){
throw new TimeConflictException("Meeting starts before it
ends.");
}
12
Code: https://bit.ly/3B39YYI
Activity: https://bit.ly/32XM308
13
Current Status Code: https://bit.ly/3B39YYI
Activity: https://bit.ly/32XM308
14