Exercise Sheet 4: November 13Th: Junit
Exercise Sheet 4: November 13Th: Junit
Exercise Sheet 4: November 13Th: Junit
Wintersemester 2014/2015
Fachbereich 2
Exercise Sheet 4
Prof. Dr. Jrg Schfer
Exercise Sheet 4
November 13th: JUnit
Note: You can use JUnit (V <= 3.8) for exercise 2 and 3 or (better) my source code of the core
classes for all exercises of this sheet!
Exercise 1
Fill the gaps in my source code of the core classes of JUnit (JUnit.zip).
Exercise 2
a) Extend JUnit with Conditional Test Cases:
1. Implement a ConditionalTestCase extending TestCase to support a public boolean
shouldRun() method. Subclasses can override the default and henceforth developers can
ex- or include certain test cases depending on context (i.e. for different platforms etc.)
2. What Design Patterns are in action here?
b) Extend JUnit with Performance Measurement:
1. Add code to ConditionalTestCase to automatically measure execution time of test methods!
2. Where would you put the results?
c) Extend JUnit with Performance Testing:
1. Add code to ConditionalTestCase to automatically test execution time of test methods!
If execution takes too long, throw an AssertionFailedError with a proper message!
2. Which Design Pattern are you using?
Exercise 3
a) Build a TestSuite tree by executing code like:
public static
TestSuite
TestSuite
TestSuite
1/2
HIS POS
Wintersemester 2014/2015
Fachbereich 2
Exercise Sheet 4
Prof. Dr. Jrg Schfer
junit.textui.TestRunner.run(suite1);
}
b)
c)
Hints
Consult the literature!
You can work in pairs, if you want!
If you want to learn a Java API, look into the java docs!
Always use the same familiar IDE (suggestion Eclipse)!
2/2