Lab 6: Testing

Black and White Box Tests

Please have a look at black-box and white-box testing before class.

  1. Getting started: Together with your team write down the equivalence classes for testing a method that returns the absolute value of an integer passed in as a parameter using the black-box methodology. Don't peek at the code yet! Now download the implementation absolute.java and give the equivalence classes for a white-box test. Develop one test case for each equivalence class. Now implement the test case using JUnit, if you are programming in Java. You are welcome, however, to use any programming language you wish.

  2. Black-box test: Look at this grading scale at the bottom of the page. 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—this is a Java program. No fair decompiling the class! Report on the results. Did you find any errors? Document the errors found, but don't correct the code.

    Grading Scale (Points = Procent)

    Points Grade ECTS Points Grade ECTS
    95-100 1,0 A 65-69 3,0 Cs
    90-94 1,3 A 60-64 3,3 C
    85-89 1,7 B 55-59 3,7 D
    80-84 2,0 B 50-54 4,0 D
    75-79 2,3 B 0-49 5,0 F
    70-74 2,7 C




  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. Design and implement test cases that exercise each path. Are there any errors in the program (besides the size of the tax bite)? Document the errors found, don't correct the code.

  4. Test Cases: Define some test cases (at least one per team member) for your Shopping List App!

  5. Reflection: Consider the examples TaxTime and GradingScale. What makes these programs hard to test? How would you refactor TaxTime to make it testable automatically with JUnit?

 

Your report, including all source code, is due next week and should include all materials. Don't forget to include your names on your report, and post the materials in the Moodle area for each team member.