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

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

**This is the last assignment for the OOSC 2013.**

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>

- Draw a control flow graph for the above method.
- 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”)
- 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.
- How many paths does this method have? Give an input example for each path.

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:

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

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 scalene^{1)}, isosceles^{2)}, or equilateral^{3)}. |
---|

(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 http://en.wikipedia.org/wiki/Triangle#Types_of_triangle */ public static enum TriangleKind { EQUILATERAL, EQUIANGULAR, SCALENE, ISOSCELES, OBLIQUE, ACUTE, OBTUSE, RIGHT_ANGLED, NOT_A_TRIANGLE }

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, * NOT_A_TRIANGLE */ public static TriangleKind kindOfTriangleByLengthsOfSides(int a, int b, int c) { return null; }

/** * Returns the most specific triangle kind based on the internal angles. * Possible values are: EQUIANGULAR, OBLIQUE, ACUTE, OBTUSE, RIGHT_ANGLED, * NOT_A_TRIANGLE */ 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 ). This method is a good candidate for a first experiment in Test-First.

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, © 2020