This is to certify that the project titled 'Code Coverage Analysis of Object Oriented Programming' submitted by Hemant Singh and Vikram Singh Bhati is an authentic work done by them under my supervision and guidance for partial fulfillment of the requirements for the award of Bachelor of Technology DegreeinComputer Science and Engineering at National Institute of Technology, Rourkela. JaBUTi works with Java Bytecode, so no source code is required for code coverage analysis. In our project, we use JaBUTi as a code coverage tool for coverage analysis of Java programs.
Finally, we have also made a comparison between the coverage and the test runs for each case study. Code coverage analysis is a quantitative approach to measure the amount of source code that is covered. Code coverage is most often used during the software testing process to determine the coverage achieved by the test cases, hence it is also referred to as test coverage.
Code coverage analysis is performed by first instrumenting the source code or intermediate binaries to read out coverage information during its execution. A testing tool, called JaBUTi (Java Bytecode Understanding and Testing), which supports the application of such criteria for testing Java programs and components, is used for our structural testing and code coverage analysis.
Motivation for our project
Objective of our project
Organization of the project report
ORGANIZATION OF THE PROJECT REPORT 13 Chapter 2
A state-based testing is implemented and test cases generated by the MACT (Method for Automatic Class Testing) tool can be used to execute functional testing. In 2000, Jianjun Zhao[10] presented a paper on dependency analysis of Java bytecode, this paper emphasizes the understanding of program dependencies in a program by analyzing the control flow and data flow which further helps in the process debugging and testing. RELATED WORK specification requirements at all, since all test cases are generated by the implementation [1].
In this paper, they described criteria based on control flow and data flow for Java component coverage testing. Control flow testing is described using all-nodes and all-edges criteria using the DUG program presentation. Data flow testing is described based on all-use criteria, which includes all-use and all-use criteria.
They used Jabuti as a testing tool and demonstrated its implementation for testing control flows and data flows. The test case file written in Netbeans IDE is imported into JaBUTi and test cases are continuously added to it using Netbeans to increase the coverage until the required coverage is obtained.
Overview
COVERAGE ANALYSIS is important to think of instead as a tool to better understand the behavior and shortcomings of the testing process and the tests in question. Additionally, by including coverage analysis as a process within the software development cycle, developers can avoid evolving code scenarios beyond what is interrogated by the tests, resulting in an increasingly out-of-date test suite that can lead to a false sense of confidence in the code.
Criteria and Metrics
CRITERIA AND METRICS 19 {
Control Flow Graph
DATA FLOW GRAPH 23
Data Flow Graph
Definition-Use Graph
A high code coverage with a large number of test runs is also an inefficient way to analyze overhead. So we need an incremental approach to cover more code with a minimum of test runs. Here we have proposed an algorithm which improves the code coverage in minimum test runs by first covering the higher priority nodes and then proceeding to lower priority nodes.
When this class file is provided as input to JaBUTi, we can generate the DUG implementation of each method. Now initially some test cases are added to the test file and it is run to measure the initial coverage (e.g. one test case is added). Test case corresponding to a higher priority node is added to the test case file and the file is executed. If the coverage after the test run is the same as before, the test case is rejected without increasing the number of test runs.
If the coverage increases, then the test case is accepted and the test count is increased by 1. We continue step by step in the same way until the coverage increases to the required level. Write the initial test cases in f-test and run it to measure the initial coverage.
Add the test case from D to f test based on high priority DUG nodes 6. Explanation: This algorithm is a simple way to proceed for the code coverage analysis of any program. Initially, some test cases are written into file f test and then executed to measure the coverage, Cov.
If the value of Cov after the run is the same as before the run, which means that despite the addition of the test case, the coverage has not increased, then we do not increase the number of test runs, N. If the consecutive values of the run Cov increase, then the value of N is increased by 1. When the value of Cov exceeds the value of Req Cov, the process stops and the values of Cov and N are returned. This algorithm can be implemented to cover the code of an object-oriented program for any of the six criteria defined by JaBUTi, namely All-Nodes-ei , All-edges-ei, All-uses-ei, All-Pot-Uses-ei, All-Nodes-ed, All-edges-ed, All -uses-ed, All-Pot-Uses-ed. In our project, we implemented the All-Nodes-ei criteria algorithm.
Toolsuite Used
Java Bytecode Understanding and Testing (JaBUTi)
It uses Java bytecode (.class files) instead of Java source code to gather the information needed to perform its activities. This feature allows the tool to be used to test any type of Java program, including Java components. It enables structural testing of Java components and also identifies which part of such components needs more testing or has not yet been covered.
Even when no source code is available, the tester can at least identify which part of the bytecode requires more testing or, in the event that a bug is identified, which part of the component is more likely to contain that bug. It uses different colors to provide hints to the tester to facilitate test generation.
Netbeans 6.9
Graphviz
Case Studies
The FactorCalculator example
CASE STUDIES 33
CASE STUDIES 35
Vending Machine Example
CASE STUDIES 37
CASE STUDIES 39
Subject Record Example
CASE STUDIES 41 Screenshots
CASE STUDIES 43
Banking System Project Example
This example consists of five class names bank.java, loan.java, account.java, bankbranch.java, customer.java.
CASE STUDIES 45
CASE STUDIES 47
CASE STUDIES 49
Overall Assessment
Conclusion
Future Work
Weyuker, Selection of software test data using data flow information, in: Proceedings of the IEEE Transactions on Software Engineering. Rothermel, Performing data flow testing on classes, in: Proceedings of Second ACM SIGSOFT Symposium on Foundations of Software Engineering, ACM Press. Zhao, Dependency analysis of Java bytecode, in: Proceedings of 24th IEEE Annual International Computer Software and Applications Conference, COMP-SAC2000, IEEE Press, Taipei, Taiwan.
Caruso, Dekkingsmetingservaring tydens funksietoets, in: Proceedings of the 15th International Conference on Software Engineering, Baltimore, MD.