Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools

Assignment 11 - Testing

Release date: Wednesday, 10.07.13 - Due date: Tuesday, 16.07.13, 23:59

This is the last assignment for the OOSC 2013.

Task 01: White-Box Testing, Example

6 points

Given is the following method bubblesort which sorts an array of int variables with a bubble sort.

<code java|h The Bubblesort Method> public int[] bubblesort(int[] numbers) { Nr. boolean change = true; 1

if (numbers.length > 1) {                //  2
  while (change) {                       //  3
   change = false;                       //  4
   for (int i = numbers.length - 1;      //  5
     i > 0;                              //  6
     i--) {                              //  7
       int i0 = numbers[i – 1];          //  8
       int i1 = numbers[i];              //  9
       if (i1 < i0) {                    // 10
         change = true;                  // 11
         numbers[i] = i0;                // 12
         numbers[i – 1] = i1;            // 13
return numbers;                          // 14

} </Code>

  1. Draw a control flow graph for the above method.
  2. Give an example input that achieves a statement coverage and write down the path. (E.g. like “input = [4], path = start → 1 → 2 → 14 → end”)
  3. Does this input also achieve a branch coverage? If yes, modify your example to not fulfill this anymore. If no, modify your example to achieve branch coverage. Write down the path sequence for this new input.
  4. How many paths does this method have? Give an input example for each path.

Task 02: White-Box Testing, Coverage

4 points

Tell us in the following table how many test cases it needs to cover all statements, all branches, all paths or all basic paths:

Control Flow 1 Control Flow 2 Control Flow 3 Control Flow 4
Basic Paths

Evaluation: 1 point for each coverage criterion for which you gave all numbers correct.

Task 03: Black-Box Testing, Triangle Classification

4 points

This is a variation of the self-assessment from the classical book from Glenford J. Myers “The Art of Software Testing”.

Your task it to enumerate meaningful equivalence classes with representative test data and expected results for a method specified as follows:

[A method has three integer parameters representing] the lengths of the sides of a triangle. The [method returns a code] that states whether the triangle is scalene1), isosceles2), or equilateral3).

(As this specification only allows integers for the side lengths, you might guess that this author has a more elementary understanding of triangles. So, don't expect this author to consider triangles that just consist of one point to be triangles.)

If you find concrete code helpful, you may have a look at the following: <code java|h Interface for a class implementing this function|h> package triangles;

import static triangles.TriangleKnowledge.TriangleKind.*;

public class TriangleKnowledge {

 * For the definitions of the different kinds of triangles you may consult
 * for example
public static enum TriangleKind {
public boolean isTriangleOfKind(int a, int b, int c, TriangleKind kind) {
	return false;
 * Returns the most specific triangle kind based on the lengths of the
 * sides. Possible values are: EQUILATERAL, SCALENE, ISOSCELES,
public static TriangleKind kindOfTriangleByLengthsOfSides(int a, int b, int c) {
	return null;
 * Returns the most specific triangle kind based on the internal angles.
public static TriangleKind kindOfTriangleByInternalAngles(int a, int b, int c) {
	return null;

} </Code>

If you like to practice Test-First development, you may try to implement kindOfTriangleByLengthsOfSides Test-First (for additional 2 points 8-) ). This method is a good candidate for a first experiment in Test-First.

Task 04: Black-Box Testing, Debunk Faulty Implementations (optional)

6 points

Solve the following tutorial: Black Box Testing

Should be real fun 8-)

no two sides are equal
exactly two sides are equal
all sides are equal
teaching/lectures/oosc/2013/assignment_11.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024