SDA SE Wiki

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

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
teaching:lectures:oosc:2011:assignment_10 [2011/07/04 11:46]
jan.nonnen
teaching:lectures:oosc:2011:assignment_10 [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== Assignment 10: Testing ======
 +<​html><​font color=darkred></​html>​**Release date: Monday, 27.06.11 - Due date: Sunday, 03.07.11, 23:​59**<​html></​font></​html>​
 +===== Task 1: Blackbox testing =====
 +^**3 points**^
 +
 +Given the following interface
 +<Code lang-java>​
 +public interface DateParser { 
 + /**
 +  * Interprets a date string of the form "​day-month-year"​
 +  * 
 +  * Day and Month can have either one or two digits (with leading zero)
 +  * Year can have two or four digits, two digits represent 21. century dates 
 +  * 
 +  * If the Month is smaller than 1, January is used, values over 12 are interpreted as December
 +  * If the Day is smaller than 1, 1 is used, similar the last possible day number is taken for inputs larger than possible.
 +  *  ​
 +  * @param input  the date string that should be interpreted
 +  * @return the interpreted date (with time 12:00:00) or null in case of an invalid input
 +  */
 + ​java.util.Date parseDate(String input); ​
 +}
 +</​Code>​
 +  - Find at least five different working and five error equivalence classes. ​
 +  - Present for each of your equivalence classes an example input and the result. ​
 +  - In the SVN folder of group00 ​ you find a zip containing the [[https://​svn.iai.uni-bonn.de/​repos/​IAI_Software/​se/​oosc2011/​group00/​Assignment10/​DateParser.zip|DateParser Eclipse project]]. This project contains a class and a test for the //​DateParser//​ interface. Add your examples from subtask 2 as test-cases to the //​GemaltoDateParserTest//​ JUnit4 class.
 +/*  - (optional) What is the bug in the //​GemaltoParser//​ class? */
 +
 +===== Task 2: Whitebox testing =====
 +^**4 points**^
 +
 +Given is the following method //sort// which sorts a field of  int variables with a bubble sort.
 +<Code lang-java>​
 +public int[] sort(int[] list) {           // Nr.
 + ​boolean change = true;                   // ​ 1 
 + if (list.length > 1) {                   // ​ 2
 +  while (change) {                        //  3
 +   ​change = false; ​                       //  4
 +   for (int i = list.length - 1;          //  5
 +     i > 0;                               // ​ 6
 +     i--) {                               // ​ 7
 +        int i1 = list[i]; ​                // ​ 8
 +        int i2 = list[i – 1];             // ​ 9
 +        if (i1 < i2) {                    // 10
 +           ​list[i] = i2;                  // 11
 +           ​list[i – 1] = i1;              // 12
 +           ​change = true;                 // 13
 +        } 
 +      } 
 +    } 
 + ​} ​
 + ​return list;                             // 14
 +}
 +</​Code>​
 +
 +    - Draw a controlflow graph for the above method.
 +    - Give an example input that  achieves a path coverage and write down the path.
 +    - 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.
 +    - Formulate a small method, which needs two different tests to cover all branches.
 +
 +/** Feedback (jn) 2011-07-04: Should provide the Format for writing the path: Start->​1->​2->​3 ...->​End,​ "​for"​ should be explained in the lecture ​
 +
 +(all) 2011-07-11: Second point should be "​statement coverage",​ as it is not possible to cover all paths with just one input.
 +
 +**/
 +
 +===== Task 3: Testing with Stubs vs Mocks ===== 
 +^**4 points**^
 +
 +In this task you will compare the two different testing techniques //Stubs// and //Mock Objects//.
 +See also the article [[http://​martinfowler.com/​articles/​mocksArentStubs.html|Mocks Aren't Stubs]] by Martin Fowler and the [[http://​www.easymock.org/​EasyMock3_0_Documentation.html|Easymock documentation]].
 +
 +Download the project [[https://​svn.iai.uni-bonn.de/​repos/​IAI_Software/​se/​oosc2011/​group00/​Assignment10/​StubVsMock.zip|StubVsMock.zip]] and import it into an Eclipse workspace. It contains a small part of a CD player software. The class //​PlayController//​ controls the player'​s hardware API defined by the interface //​CDPlayer//​.
 +
 +  - Complete the two unit test classes StubTest and MockTest using the corresponding testing techniques.
 +  - Explain the advantages/​disadvantages of the two different techniques.
 +
 +===== Optional Tasks =====
 +
 +
 +===== How to start =====
 +  * Install [[http://​www.eclipse.org/​downloads|eclipse]].
 +  * Download ''​{{:​teaching:​lectures:​oosc:​2010:​a1t01-t04_university.zip|tutorial}}''​ project and import it.
 +  * Your solutions should be in the folder ''​src''​.
 +  * You should never change any class in the ''​tst''​ folder.
 +  * The tasks are described in more detail in the mentioned files in the ''​tst''​ folder.
 +  * The first thing you should do is to run the tests(({{:​teaching:​lectures:​oosc:​2008:​exercises:​images:​how_to_run_junit_tests.png|}})). ​
 +  * You will see that 11 of 14 tests are failing (({{:​teaching:​lectures:​oosc:​2008:​exercises:​images:​you_start_with_11_failures.png|}})). This means that we made assertions about the base code that are not true for the current implementation. ​
 +  * After you solved all tasks 12 of 14 tests should be successful (({{:​teaching:​lectures:​oosc:​2008:​exercises:​images:​green_enough_tests.png|}})). If you decide to solve even the extra tasks everything should be green (({{:​teaching:​lectures:​oosc:​2008:​exercises:​images:​all_tests_successful.png|}})) and there should be even more tests.
 +
 +
 +===== Optional Task 01: Persons and Addresses (Identity vs Equality of Objects) =====
 +^**3 points**^
 +
 +
 +**After you have solved this task, you should be able to understand and explain:**
 +
 +  * ... the difference between the two concepts //​equality//​ and //​identity//​ of objects.
 +  * See ''​X1T01_AddressTest''​ in the package ''​people''​ in the ''​tst''​ folder.
 +
 +
 +===== Optional Task 02: Number Generators (Implementing Interfaces) =====
 +^**3 points**^
 +
 +**After you have solved this task, you should be able to understand and explain:**
 +
 +  * ... how you write classes that implement interfaces.
 +  * ... how you write methods that can work on any of these classes.
 +  * See ''​X1T02_NumberGeneratorTest''​ in the package ''​numbers''​ in the ''​tst''​ folder.
 +
 +
 +
 +
 +
 +===== Optional Task 03: Students and Professors are Persons (Class Inheritance) =====
 +^**4 points**^
 +
 +**After you have solved this task, you should be able to understand and explain:​** ​
 +
 +  * ... how you can create subclasses.
 +  * ... how class extension relates to interface implementation.
 +  * ... how you can make use of inheritance to reuse common functionality.
 +  * See ''​X1T03_PersonsStudentsProfessors''​ in the package ''​university''​ in the ''​tst''​ folder.
 +
 +  * We would like to see a very simple use of a [[http://​en.wikipedia.org/​wiki/​template_method_pattern#​example_.28in_java.29|template method]].
 +
 +
 +
 +
 +===== Optional Task 04: The University (Using Frameworks) =====
 +^**4 points**^
 +
 +**After you have solved this task, you should be able to understand and explain:​** ​
 +
 +  * ... how to let your classes implement interfaces so that framework classes know what to expect from them.
 +  * ... how to configure framework classes, so that you can extend their behavior without modifying them.
 +  * See ''​X1T04_StudentTest''​ in the package ''​university''​ in the ''​tst''​ folder.
 +
 +
 +===== Screenshots =====
 +
 +
  
teaching/lectures/oosc/2011/assignment_10.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019