Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Release date: Wednesday, 25.06.14 - Due date: Sunday, 29.06.14, 23:59
9 points + [4 points] |
---|
In the lecture we started to implement RomanNumerals again. This time we used the TDD approach. Continue with this implementation for 30 minutes. As you know, there are already some sample solutions. But, this time you have to strictly follow the TDD steps:
After 30 minutes you are done, even if the functionality is not complete. Start with the code in A11T43_TestDrivenRomans
. Copying from the existing implementation is only allowed, when it still keeps the step 1 and 2 as small as possible. We will only evaluate, whether you followed the TDD steps strictly and whether your increments were correct.
There are two ways you can prove to us, that you followed the approach:
Manually: By manually committing after each step.
Automatically: By installing and starting the automatic saver.
<experiment>
Optional (with no points): Allow us to use your repository as well for the experiment. </experiment>
Optional Discussion:
Thoroughly discuss the quality of your test with respect to White-Box and Black-Box criteria.
12 points |
---|
Imagine you have to test the class Triangle, whose source code you do not know.
The class's only public method of interest is Triangle.contains(Triangle t)
and it is supposed to check if the triangle contains some other triangle t. For example the green triangle on the right contains the red one, i.e. greenTriangle.contains(redTriangle)
should be true. On the other hand the red doesn't contain the green one, i.e. redTriangle.contains(greenTriangle)
should be false.
a) Create a test plan:
b) Debunk the faulty implementations
Your company decided that it is too difficult5) to develop the contains(..)
method within the company. So they announced that they want to buy an implementation. In response they got 17 implementations, but they doubt that many of them are correct. You got the job to find the implementation that is working. Of course you didn't get the source code, but you are a smart tester. Write some tests to find the implementation your company should actually buy. If you did the optional step, you can use the tests that your produced. Here is your guide to the source code:
A11T44_Triangles
cls
contains the implementations Triangle00
till Triangle16
.tst
you find the class geometry.TriangleTest
. This test exercises all the implementations using the same test methods for each.6)Triangle14
and Triangle16
.Triangle14
and Triangle16
are out.ifOneTriangleIsVeryLargeAndTheOtherVerySmall
is annotated with @Ignore
and therefore ignored.@Ignore
annotation and run the tests again.10 points |
---|
Given is the following class Supplies
that simulates the supplies in a station of our cloud BAKERY 2100.
<code java|h The Model of the Supplies at a cloud BAKERY 2100 Station> public class Supplies {
private Map<Ingredient, Quantity> supplies = new HashMap<>(); private Map<Long, Map<Ingredient, Quantity>> reservations = new HashMap<>(); private Quantity availableQuantity(Ingredient ingredient) { // Calculates the available amount of the ingredient // based on supplies and reservations. }
public void reserve(Ingredient ingredient, Quantity requested, long orderId) throws NotEnoughIngredientsException { // start Quantity available = availableQuantity(ingredient); // 1 if (available.compareTo(requested) < 0) { // 2 throw new NotEnoughIngredientsException("Not enough of ingredient " // 3 + ingredient + ". Requested=" + requested + ", available=" + available); } Map<Ingredient, Quantity> reservation = reservations.get(orderId); // 4 if (reservation == null) { // 5 reservation = new HashMap<>(); // 6 reservations.put(orderId, reservation); // 7 } Quantity reservedQuantity = reservation.get(ingredient); // 8 if (reservedQuantity == null) { // 9 reservation.put(ingredient, requested); // 10 } else { reservedQuantity.add(requested); // 11 } } // end
// ... more methods ...
} </Code>
reserve
method. supplies
and reservations
. Then we could consider the state of these two fields as part of the input data. Give an example input data that achieve high statement coverage and write down the execution path. (E.g., if we want to reserve salt, but there is no salt an exception is thrown. You might haven written “supplies={sugar → 5kg, flour → 10kg, milk → 1l, wine → 3l}, reservations={123 → {milk → 200ml}, 124 → {wine → 300ml}}, ingredient=salt, requested=5g, orderId=200; execution path = start-1-2-3-end”) assertEquals(“I”, roman(1));
.return “I”;
.createTriangle(..)
method to create triangles. Don't use the constructors directly!createTriangle(..)
method to create triangles!