B15 Informatik 3 (Info3)

Website of Prof. Dr. Barne Kleinen, Professor for Media Informatics (Bachelor/Master) at HTW Berlin

Exercise 08: Black and White Box Tests

     <prev next>

Assignment

After exploring Unit Testing in the last exercise, we will be looking at black-box and white-box testing in this second testing exercise.

Source code for this exercise: https://github.com/htw-imi-info3-archive/lab-08-blackwhite

  1. Getting started: Give the equivalence classes for testing a method that determines the absolute value of an integer using the black-box methodology. Don’t peek at the code yet! Now check out absolute.java in the repository and give the equivalence classes for a white-box test. Develop one test case for each equivalence class using JUnit.
  2. Black-box test: Look at the grading scale at the bottom of the page (Which is not the [grading scale for this course]({{ site.BaseURL }}/studies/grading/grading-scale) ). Give the equivalence classes for a program that loops until a -1 is entered, asking for the number of points on this scale, prints the appropriate letter grade (A-F), and then prints the average number of points when -1 has been entered. Develop one test case for each equivalence class. Test your test cases with GradingScale.class. No fair decompiling the class! Report on the results. Did you find any errors?
  3. White-box test / path coverage: Examine the code for TaxTime.java. Draw a code graph of the main class! How many independent paths are there? What are the conditions that cause each of the paths to be taken? Draw up a table giving you an overview of the conditions. Give test cases that exercise each path. Are there any errors in the program (besides the size of the tax bite)?
  4. Reflection Consider the last two examples, especially TaxTime. What makes this programs hard to test? How would you refactor TaxTime to make it testable automatically with JUnit?

Grading Scale (Points = Procent)

PointsGradeECTSPointsGradeECTS
95-1001,0A65-693,0C
90-941,3A60-643,3C
85-891,7B55-593,7D
80-842,0B50-544,0D
75-792,3B0-495,0F
70-742,7C

Lab Writeup

Submit your Report as PDF to moodle.