CSC 532:
SOFTWARE TESTING ASSIGNMENT
OSINUGA OLUWASEUN
090805049
LECTURER: PROF. C.O UWADIA
1a. PROGRAM LISTING
Imports [Link]
Public Class exam
Dim rdr As OleDbDataReader = Nothing
Dim con As OleDbConnection = Nothing
Dim cmd As OleDbCommand = Nothing
Dim cs As String = "Provider=[Link].12.0;Data
Source=c:\Users\Admin2\[Link];Persist Security Info=False;"
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim score As Integer = 0
Dim percent As Integer = 0
Dim a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 As String
Dim result As String
Dim sid As String
'Validate that
there is no empty column when inputting the student id
Try
If [Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] = "" Or
[Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] = "" Or
[Link] = "" Then
[Link]("Please enter a valid student ID", "Input Error",
[Link], [Link])
[Link]()
Exit Sub
End If
'Validate that answers inputted are either "A" or "B" or "C" or "D" or "E" in caps.
'Comparing the ascii code of each letter
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
If Asc(CStr([Link])) < 65 Or Asc(CStr([Link])) > 69 Then
[Link]("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
[Link], [Link])
Exit Sub
End If
'Give a zero score for any blank answer
If [Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] =
"" Or [Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] = ""
Or [Link] = "" Or [Link] = "" Then
score = 0
End If
Catch ex As Exception
[Link]([Link], "Error", [Link], [Link])
End Try
Try
'Fetch correct answer key from database
'The answer key is the first record in the database
con = New OleDbConnection(cs)
[Link]()
Dim ct As String = "select q1, q2, q3, q4, q5, q6, q7, q8, q9, q10 from score where id = 1"
cmd = New OleDbCommand(ct, con)
rdr = [Link]()
If [Link] Then
'aasigns correct answer keys to variables
a1 = [Link](0)
a2 = [Link](1)
a3 = [Link](2)
a4 = [Link](3)
a5 = [Link](4)
a6 = [Link](5)
a7 = [Link](6)
a8 = [Link](7)
a9 = [Link](8)
a10 = [Link](9)
End If
Catch ex As Exception
[Link]([Link], "Error", [Link], [Link])
End Try
[Link]()
'Increments score by 1 if student's response equals correct answers in the database
If [Link] = a1 Then
score = score + 1
End If
If [Link] = a2 Then
score = score + 1
End If
If [Link] = a3 Then
score = score + 1
End If
If [Link] = a4 Then
score = score + 1
End If
If [Link] = a5 Then
score = score + 1
End If
If [Link] = a6 Then
score = score + 1
End If
If [Link] = a7 Then
score = score + 1
End If
If [Link] = a8 Then
score = score + 1
End If
If [Link] = a9 Then
score = score + 1
End If
If [Link] = a10 Then
score = score + 1
End If
percent = (score / 10) * 100
[Link] = score
[Link] = percent
Try
'stores students id, score and percentage into the database
con = New OleDbConnection(cs)
[Link]()
Dim cb As String = "insert into
score(1,2,3,4,5,6,7,8,9,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,m,p) values(@d1, @d2, @d3, @d4, @d5,
@d6, @d7, @d8, @d9, @d10, @d11, @d12, @d13, @d14, @d15, @d16, @d17, @d18, @d19,
@d20, @d21)"
cmd = New OleDbCommand(cb, con)
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
[Link](New
OleDbParameter("@d1", [Link], 10, "1"))
OleDbParameter("@d2", [Link], 10, "2"))
OleDbParameter("@d3", [Link], 10, "3"))
OleDbParameter("@d4", [Link], 10, "4"))
OleDbParameter("@d5", [Link], 10, "5"))
OleDbParameter("@d6", [Link], 10, "6"))
OleDbParameter("@d7", [Link], 10, "7"))
OleDbParameter("@d8", [Link], 10, "8"))
OleDbParameter("@d9", [Link], 10, "9"))
OleDbParameter("@d10", [Link], 10, "q1"))
OleDbParameter("@d11", [Link], 10, "q2"))
OleDbParameter("@d12", [Link], 10, "q3"))
OleDbParameter("@d13", [Link], 10, "q4"))
OleDbParameter("@d14", [Link], 10, "q5"))
OleDbParameter("@d15", [Link], 10, "q6"))
OleDbParameter("@d16", [Link], 10, "q7"))
OleDbParameter("@d17", [Link], 10, "q8"))
OleDbParameter("@d18", [Link], 10, "q9"))
OleDbParameter("@d19", [Link], 10, "q10"))
OleDbParameter("@d20", [Link], 10, "m"))
OleDbParameter("@d21", [Link], 10, "p"))
[Link]("@d1").Value = [Link]
[Link]("@d2").Value = [Link]
[Link]("@d3").Value = [Link]
[Link]("@d4").Value = [Link]
[Link]("@d5").Value = [Link]
[Link]("@d6").Value = [Link]
[Link]("@d7").Value = [Link]
[Link]("@d8").Value = [Link]
[Link]("@d9").Value = [Link]
[Link]("@d10").Value = [Link]
[Link]("@d11").Value = [Link]
[Link]("@d12").Value = [Link]
[Link]("@d13").Value = [Link]
[Link]("@d14").Value = [Link]
[Link]("@d15").Value = [Link]
[Link]("@d16").Value = [Link]
[Link]("@d17").Value = [Link]
[Link]("@d18").Value = [Link]
[Link]("@d19").Value = [Link]
[Link]("@d20").Value = score
[Link]("@d21").Value = percent
[Link]()
[Link]("Successfully saved", "Student Score", [Link],
[Link])
[Link]()
Catch ex As Exception
[Link]([Link], "Error", [Link], [Link])
End Try
'Displays the students id, score and percentage on the screen
sid = [Link] + [Link] + [Link] + [Link] + [Link] +
[Link] + [Link] + [Link] + [Link]
result = sid & vbTab & [Link] & vbTab & [Link] & vbCrLf
[Link](result)
End Sub
End Class
1b. OUTPUT
WHITE BOX TESTING
(Control Flow Graph)
CY
CLOMATIC COMPLEXITY
1. V(G) = 5 regions
2. V(G) = 20 Edges 17 Nodes + 2 = 5
3. V(G) = 4 Predicate Nodes + 1 = 5
BASIS PATHS
P1: 1-2-4-6-8-9-10-12-13-14-15-16-17
P2: 1-2-4-6-7-8-9-10-12-13-14-15-16-17
P3: 1-2-4-6-7-8-9-10-12-13-14-15-16-17
P4: 1-2-3-1-
P5: 1-2-4-5-1-.
CREATING TESTS:
(E.g. Assume key answers to be
A D A B E C C D B E)
Path 1 test case: Valid and non-empty responses but has wrong answers
Value (Path 1) = 090805049ADABEECDBE
Expected Result: Correct output of score and percentage. Score is Zero for
every wrong answer
Path 2 test case: Valid answers which consists of blank responses
Value (Path 2) = 090805049,,,ADAEEBE
(Where , is a blank answer)
Expected Result: Score is zero for every blank response
Path 3 test case: Valid, non-empty responses and correct answers
Value (Path 3) = 090805049ADABEECDBE
Expected Result: Correct output of score and percentage.
Path 4 test case: Empty students ID
Value (Path 4) =,,,,,,,,, ADABEECDBE
(Where , represent a blank id)
Expected Result: Error Message
Path 5 test case: Responses aside A, B, C, D, E
090805049ADABGHABBB
Expected Result: Error Message
EQUIVALENT PARTITIONING TECHNIQUES
1. Student ID:
Input Condition: non-empty 9 digit length
Chosen Values: 090805049, 090805008
2. Answers:
Input Condition:
a. Boolean: An answer may or may not be present
b. Set: An answer must be either A or B or C or D or E
c. Range: input must be between 0 and 10 answers
Chosen Values: ADDADADDAA
ADD DAA AA