0% found this document useful (0 votes)
121 views38 pages

Jabuti (Java Bytecode Understanding and Testing) : Topics To Be Discussed

Click Execute. This will run the test cases and generate coverage report.

Uploaded by

Subir Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views38 pages

Jabuti (Java Bytecode Understanding and Testing) : Topics To Be Discussed

Click Execute. This will run the test cases and generate coverage report.

Uploaded by

Subir Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

24-01-2023

JABUTI (JAVA BYTECODE


UNDERSTANDING AND TESTING)

Dr. Madhusmita Sahu


Assistant Professor
Department of Computer Science and Information Technology

TOPICS TO BE DISCUSSED

• JaBuTi
• Installation
• Using JaBuTi
• Assignment
24-01-2023

JABUTI (JAVA BYTECODE


UNDERSTANDING AND TESTING)

• JaBUTi is a set of tools designed for understanding and testing of Java


programs.
• The main advantage of JaBUTi is that it does not require the Java source code
to perform its activities.
• JaBUTi is designed to work with Java bytecode such that no source code is
required to perform its activities.

JABUTI (JAVA BYTECODE


UNDERSTANDING AND TESTING)

• It is composed
• by a coverage analysis tool,
• by a slicing tool, and
• by a complexity metric’s measure tool.
• The coverage tool can be used to assess the quality of a given test set or to
generate test set based on different control-flow and data-flow testing criteria.
• The slicing tool can be used to identify fault-prone regions in the code, being useful
for debugging and also for program understanding.
• The complexity metric’s measure tool can be used to identify the complexity and
the size of each class under testing, based on static information.
24-01-2023

JABUTI (JAVA BYTECODE


UNDERSTANDING AND TESTING)

REQUIREMENTS

• Install Java.
• Install NetBeans.
• Install Graphviz 2.26.
24-01-2023

INSTALLATION

• Create a folder named jab (D:\jab).


• Create two folders named Examples and Tools under jab.
• Create folder Jabuti under Tools.
• Create folder lib under Jabuti.
• Copy jabuti.jar to D:\jab.
• Copy bcel-6.4.1.jar, crimson.jar, junit-4.13.2.jar, hamcrest-core-1.3.jar, to
D:\jab\Tools\Jabuti\lib
• Right click on jabuti.jar and Extract to Jabuti\.

INSTALLATION

• Set Path for Jabuti


• D:\jab; D:\jab\Tools\Jabuti\lib
• Set Classpath for Jabuti
• D:\jab; D:\jab\Tools\Jabuti\lib
• Set Path for Graphviz
• C:\Program Files (x86)\Graphviz2.26\bin\Gvedit.exe
• Set Classpath for Graphviz
• C:\Program Files (x86)\Graphviz2.26\bin\Gvedit.exe
24-01-2023

SET PATH AND CLASSPATH

• Right Click on This PC->Properties

SET PATH AND CLASSPATH


24-01-2023

SET PATH AND CLASSPATH

SET PATH AND CLASSPATH

• Click on Advanced System Settings->Environment Variables


24-01-2023

SET PATH AND CLASSPATH

SET PATH AND CLASSPATH

• Click on Path variable under User variables for user


• Click on New
• Enter the path
• Click Ok
24-01-2023

SET PATH AND CLASSPATH

SET PATH AND CLASSPATH

• Click on New under User variables for user


• Variable name: ClassPath
• Variable value: C:\Program Files\Java\jdk-18.0.2.1\bin; D:\jab; D:\jab\Tools\Jabuti\lib;
C:\Program Files (x86)\Graphviz2.26\bin\Gvedit.exe
• Click Ok->Ok->Ok
24-01-2023

SET PATH AND CLASSPATH

USING NETBEANS

• Click File->New Project->Java with Ant->Java Application


24-01-2023

USING NETBEANS

USING NETBEANS

• Click Next.
• Give Project Name: Circle
• Give Project Location: D:\jab\Examples
24-01-2023

USING NETBEANS

USING NETBEANS

• Click Finish
24-01-2023

USING NETBEANS

USING NETBEANS

• Right click on circle package.


• Select New->Java Class
24-01-2023

USING NETBEANS

USING NETBEANS

• Class Name: CircleAreaPeri


• Package: circle
24-01-2023

USING NETBEANS

USING NETBEANS

• Click Finish
24-01-2023

USING NETBEANS

USING NETBEANS

• Write code for CircleAreaPeri.Java


24-01-2023

USING NETBEANS

• package circle;

• public class CircleAreaPeri {

• public int area(int r)

• {

• int area = (int) (3.14159 * (r * r));

• return(area);

• }

• public double perimeter(double r)

• {

• double perimeter = 2 * 3.14159 * r;

• return(perimeter);

• }

• }

USING NETBEANS

• Right click on CircleAreaPeri.java->Tools->Create/Update Test->Ok


24-01-2023

USING NETBEANS

USING NETBEANS
24-01-2023

USING NETBEANS

• Click Ok

USING NETBEANS
24-01-2023

USING NETBEANS

• This will create CircleAreaPeriTest.Java

USING NETBEANS

• Right click on CircleAreaPeri.java->Tools->Create/Update Test->Ok


• Write the code for CircleAreaPeriTest.java.
• Comment the fail statement.
• Give values for input and expected output.
24-01-2023

USING NETBEANS

• package circle;

• import org.junit.After;
• import org.junit.AfterClass;
• import org.junit.Before;
• import org.junit.BeforeClass;
• import org.junit.Test;
• import static org.junit.Assert.*;

USING NETBEANS

• public class CircleAreaPeriTest {


• @Test
• public void testArea() {
• System.out.println("area");
• int r = 2;
• CircleAreaPeri instance = new CircleAreaPeri();
• int expResult = 12;
• int result = instance.area(r);
• assertEquals(expResult, result);
• // TODO review the generated test code and remove the default call to
fail.
24-01-2023

USING NETBEANS

• //fail("The test case is a prototype.");


• }
• @Test
• public void testPerimeter() {
• System.out.println("perimeter");
• double r = 2.5;
• CircleAreaPeri instance = new CircleAreaPeri();
• double expResult = 15.70795;
• double result = instance.perimeter(r);
• assertEquals(expResult, result, 0);

USING NETBEANS

• // TODO review the generated test code and remove the default call to fail.
• //fail("The test case is a prototype.");
• }
• }
24-01-2023

USING NETBEANS

• Right click on Libraries->Add Jar/Folder.


• Select all jar files under E:\jab\Tools\Jabuti\lib.
• Click OK.

USING NETBEANS
24-01-2023

USING NETBEANS

USING NETBEANS

• Right click on CircleAreaPeriTest.java->Run file.


• All test cases should pass. (Green colour will appear)
24-01-2023

USING NETBEANS

USING NETBEANS
24-01-2023

USING NETBEANS

• Copy CircleAreaPeriTest.java to D:\jab\Examples\Circle\src\circle.


(CircleAreaPeriTest.java is present under test folder inside circle)
• Copy CircleAreaPeriTest.class to D:\jab\Examples\Circle\build\classes\circle.
(CircleAreaPeriTest.class is present under test folder inside build folder)

USING JABUTI

• Open Jabuti.jar (D:\jab\Jabuti.jar) by double click.


• File->Open class->CircleAreaPeri.class.
• Classpath: D:\jab\Examples\Circle\build\classes.
• Click Open.
24-01-2023

USING JABUTI

USING JABUTI

• Expand Circle.
• Select CircleAreaPeri.class to Instrument.
• Click button >> under Classes to Instrument.
• Give Project name: circle (for example).
• Classpath: D:\jab\Examples\Circle\build\classes.
• Click OK.
24-01-2023

USING JABUTI

USING JABUTI
24-01-2023

USING JABUTI

• TestCase->Executing Junit Test Set.


• Path to Junit test suite source code: D:\jab\Examples\Circle\src
• Path to Junit test suite binary code: D:\jab\Examples\Circle\build\classes
• Test suite full qualified name: circle.CircleAreaPeriTest (Packagename.Testclass
filename)
• Jabuti’s library: D:\jab\JaBUTi-1.1r0
• Other Application Specific Libraries: D:\jab\Examples\Circle\build\classes
• Javac: C:\Program Files\Java\jdk-18.0.2.1\bin\javac.exe
• Java: C:\Program Files\Java\jdk-18.0.2.1\bin\java.exe
• Trace file name: D:\jab\Examples\Circle\circle.trc
• Click on Compile Test Cases.

USING JABUTI
24-01-2023

USING JABUTI

USING JABUTI
24-01-2023

USING JABUTI

• Click on Run Normally (No Trace).

USING JABUTI
24-01-2023

USING JABUTI

• Click on Run Collecting Trace Information.

USING JABUTI
24-01-2023

USING JABUTI

• Close the tab.


• Click on Update on the top indicated by Red button.

USING JABUTI
24-01-2023

USING JABUTI

USING JABUTI

• View summary of the test case coverage from Summary menu.


24-01-2023

USING JABUTI

USING JABUTI
24-01-2023

USING JABUTI

USING JABUTI
24-01-2023

USING JABUTI

USING JABUTI
24-01-2023

USING JABUTI

• View complexity metrics from Visualization menu.

USING JABUTI
24-01-2023

ASSIGNMENT

• Write a program to generate Fibonacci series.


• Write a program to perform bubble sort to sort a set of integers.
• Write a program to add two matrices and display the resultant matrix.
• Write a program to find factorial of a number.
• Write a program to display transpose of a matrix.
• Write a program to check whether a number is prime or not.
• Write a program to check whether a number is palindrome or not.
• Write a program for a simple calculator that performs addition, subtraction,
multiplication and division of two numbers.

You might also like