Objectives

• The goals for this assignment are to (1) use a source code coverage measurement tool, and (2) practice questions related to the material on graph coverage.

Note that you can use the tool provided on the textbook website (click here) to generate the test requirements. This will help you answer parts 1.b, 1.e, and 2.b.

1. (15 points) You are given a graph with the following nodes and edges:

• Set of nodes = { 1, 2, 3, 4, 5, 6, 7}
• Set of initial nodes = {1}
• Set of final nodes = {7}
• Set of edges = {(1, 2), (2, 3), (2, 4), (4, 3), (3, 5), (3, 6), (5, 3), (6, 1), (1, 7)}

Consider the following three test paths:

1. [1, 2, 4, 3, 6, 1, 7]
2. [1, 2, 3, 5, 3, 6, 1, 7]
3. [1, 2, 4, 3, 5, 3, 6, 1, 2, 3, 6, 1, 7]

Answer the following questions based on the above graph and test paths.

1. Draw the graph.

2. List the test requirements for edge-pair coverage.

3. Do the test paths 1 and 2 (taken together) satisfy edge-pair coverage? If not, identify what is missing.

4. Consider the simple path [1, 2, 4, 3, 6]. Does test path 3 tour the simple path directly? With a sidetrip? If so, identify the sidetrip. With a detour? If so, identify the detour.

5. List the test requirements for node coverage, edge coverage, and prime path coverage on the graph.

6. List test paths that achieve node coverage but not edge coverage on the graph.

7. List test paths that achieve edge coverage but not prime path coverage on the graph.

2. (10 points) Consider the main method provided in the PrimeSieve class on the website linked here. Answer the following questions:

1. Draw the control flow graph for the statements inside the main method.

2. Enumerate the test requirements for node coverage, edge coverage, and prime path coverage for the above graph.

3. List test paths that achieve node coverage but not edge coverage on the graph.

4. List test paths that achieve edge coverage but not prime path coverage on the graph.

3. (5 points) Using your own code from assignment A1, measure code coverage in the form of statement, branch, and method coverage using any Java code coverage analysis tool of your choice. Include the coverage numbers in your report.

If your IDE doesn't already include such a tool, you can choose one from this webpage. For example, instructions for installing and using ECLEmma/JaCoCo as an Eclipse plugin are given below..

How to install

1. Go to Help -> Install New Software...
3. Enter location: http://update.eclemma.org/ name : EclEmma Update Site and click ok.
4. After clicking, it will take some time to EclEmma plugin appear in the text box.
5. Click Select All and then Next.
6. Click next, accept license agreement and client Finish. Ignore the security warning and restart eclipse.

How to use

1. Select the project for A1.
2. At the top where you have the Play buttons for running programs, click on the down-arrow next to the play button that has a red and green rectangle on the bottom-left of the play button.
3. You can run the project as JUnit or as Java Application.
4. You should be able to view Coverage in the view Console. You can expand the package in the console and view coverage for individual files. If you run multiple times as you add test cases, you can view new coverage by selecting the sessions from a dropdown menu (the one with gears).
5. You can also right click on the project for A1, and select Properties. Click on Coverage to see a summary of various types of coverage.
6. The code view will show colors indicating which parts of the code are covered (or not).
• green for fully covered lines
• yellow for partly covered lines
• red for lines that have not been executed at all
7. Copy the coverage numbers and include it in your report.

Submission

Type the answers to the above questions in a document called a3.pdf. Submit the file using Assignment Submission in Canvas.