Software Testing Assignment: Osinuga Oluwaseun 090805049
Software Testing Assignment: Osinuga Oluwaseun 090805049
Exit Sub
End If
If Asc(CStr(TextBox15.Text)) < 65 Or Asc(CStr(TextBox16.Text)) > 69 Then
MessageBox.Show("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If Asc(CStr(TextBox17.Text)) < 65 Or Asc(CStr(TextBox18.Text)) > 69 Then
MessageBox.Show("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If Asc(CStr(TextBox18.Text)) < 65 Or Asc(CStr(TextBox18.Text)) > 69 Then
MessageBox.Show("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If Asc(CStr(TextBox19.Text)) < 65 Or Asc(CStr(TextBox19.Text)) > 69 Then
MessageBox.Show("Answers should either be A, B, C, D or E (IN CAPS)", "Input Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
'Give a zero score for any blank answer
If TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text =
"" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = ""
Or TextBox18.Text = "" Or TextBox19.Text = "" Then
score = 0
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Try
'Fetch correct answer key from database
'The answer key is the first record in the database
con = New OleDbConnection(cs)
con.Open()
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 = cmd.ExecuteReader()
If rdr.Read Then
'aasigns correct answer keys to variables
a1 = rdr.GetString(0)
a2 = rdr.GetString(1)
a3 = rdr.GetString(2)
a4 = rdr.GetString(3)
a5 = rdr.GetString(4)
a6 = rdr.GetString(5)
a7 = rdr.GetString(6)
a8 = rdr.GetString(7)
a9 = rdr.GetString(8)
a10 = rdr.GetString(9)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
con.Close()
'Increments score by 1 if student's response equals correct answers in the database
If TextBox10.Text = a1 Then
score = score + 1
End If
If TextBox11.Text = a2 Then
score = score + 1
End If
If TextBox12.Text = a3 Then
score = score + 1
End If
If TextBox13.Text = a4 Then
score = score + 1
End If
If TextBox14.Text = a5 Then
score = score + 1
End If
If TextBox15.Text = a6 Then
score = score + 1
End If
If TextBox16.Text = a7 Then
score = score + 1
End If
If TextBox17.Text = a8 Then
score = score + 1
End If
If TextBox18.Text = a9 Then
score = score + 1
End If
If TextBox19.Text = a10 Then
score = score + 1
End If
percent = (score / 10) * 100
TextBox20.Text = score
TextBox21.Text = percent
Try
'stores students id, score and percentage into the database
con = New OleDbConnection(cs)
con.Open()
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.Parameters("@d1").Value = TextBox1.Text
cmd.Parameters("@d2").Value = TextBox2.Text
cmd.Parameters("@d3").Value = TextBox3.Text
cmd.Parameters("@d4").Value = TextBox4.Text
cmd.Parameters("@d5").Value = TextBox5.Text
cmd.Parameters("@d6").Value = TextBox6.Text
cmd.Parameters("@d7").Value = TextBox7.Text
cmd.Parameters("@d8").Value = TextBox8.Text
cmd.Parameters("@d9").Value = TextBox9.Text
cmd.Parameters("@d10").Value = TextBox10.Text
cmd.Parameters("@d11").Value = TextBox11.Text
cmd.Parameters("@d12").Value = TextBox12.Text
cmd.Parameters("@d13").Value = TextBox13.Text
cmd.Parameters("@d14").Value = TextBox14.Text
cmd.Parameters("@d15").Value = TextBox15.Text
cmd.Parameters("@d16").Value = TextBox16.Text
cmd.Parameters("@d17").Value = TextBox17.Text
cmd.Parameters("@d18").Value = TextBox19.Text
cmd.Parameters("@d19").Value = TextBox19.Text
cmd.Parameters("@d20").Value = score
cmd.Parameters("@d21").Value = percent
cmd.ExecuteReader()
MessageBox.Show("Successfully saved", "Student Score", MessageBoxButtons.OK,
MessageBoxIcon.Information)
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
'Displays the students id, score and percentage on the screen
sid = TextBox1.Text + TextBox2.Text + TextBox3.Text + TextBox4.Text + TextBox5.Text +
TextBox6.Text + TextBox7.Text + TextBox8.Text + TextBox9.Text
result = sid & vbTab & TextBox20.Text & vbTab & TextBox21.Text & vbCrLf
ListBox1.Items.Add(result)
End Sub
End Class
1b. OUTPUT
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