A3. Graph Coverage for Source Code
DUE:
11:59PM, Tuesday 28 February 2016
30 points
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.
Tasks
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.
-
(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, 2, 4, 3, 6, 1, 7]
- [1, 2, 3, 5, 3, 6, 1, 7]
- [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.
- Draw the graph.
- List the test requirements for edge-pair coverage.
- Do the test paths 1 and 2 (taken together) satisfy edge-pair coverage? If not, identify what is missing.
- 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.
- List the test requirements for node coverage, edge coverage, and prime path coverage on the graph.
- List test paths that achieve node coverage but not edge coverage on the graph.
- List test paths that achieve edge coverage but not prime path coverage on the graph.
-
(10 points) Consider the main method provided in the PrimeSieve class on the website linked here. Answer the following questions:
- Draw the control flow graph for the statements inside the main method.
- Enumerate the test requirements for node coverage, edge coverage, and prime path coverage for the above graph.
- List test paths that achieve node coverage but not edge coverage on the graph.
- List test paths that achieve edge coverage but not prime path coverage on the graph.
- (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
- Go to Help -> Install New Software...
- Click on Add...
- Enter location: http://update.eclemma.org/ name : EclEmma Update Site and click ok.
- After clicking, it will take some time to EclEmma plugin appear in the text box.
- Click Select All and then Next.
- Click next, accept license agreement and client Finish. Ignore the security warning and restart eclipse.
How to use
- Select the project for A1.
- 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.
- You can run the project as JUnit or as Java Application.
- 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).
- 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.
- 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
- 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.