© Dr. A. Williams, Fall 2008 - Present Software Quality Assurance – Clover Lab 1 Tutorial / lab 2: Code instrumentation Goals of this session: 1.Create.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introduction to C Programming
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Introducing JavaScript
Computer Science 2212a/b - UWO1 Structural Testing Motivation The gcov Tool An example using gcov How does gcov do it gcov subtleties Further structural.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Written by: Dr. JJ Shepherd
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
1 Fall 2008ACS-1903 for Loop Reading files String conversions Random class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 4 Control Structures I: Selection.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
2  Problem Definition  Project Purpose – Building Obfuscator  Obfuscation Quality  Obfuscation Using Opaque Predicates  Future Planning.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Coverage tools Program is typically compiled with special options, to add extra source or object code. –Additional data structures, such as a flow graph,
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.
Java. Features of Java Architecture Neutral and Portable o Write once, run anywhere o Java Virtual Machine (JVM) Object Oriented o Classes encapsulate.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Chapter 4: Control Structures I J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Programming in Java Unit 4. Learning outcome:  LO2: Be able to design Java solutions  LO3: Be able to implement Java solutions Assessment criteria:
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Visual Basic Programming
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
I Power Higher Computing Software Development High Level Language Constructs.
Kirk Scott Computer Science The University of Alaska Anchorage 1.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Chapter 4 Control Structures I. Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate.
Chapter 5: Making Decisions. Objectives Plan decision-making logic Make decisions with the if and if…else structures Use multiple statements in if and.
Semantics (1).
© Spiros Mancoridis Software Engineering (Unit Testing Tools) Dependable Software Systems Topics in Unit Testing Tools Material drawn from [ junit.org,
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
1 b Boolean expressions b truth tables b conditional operator b switch statement b repetition statements: whilewhile do/whiledo/while forfor Lecture 3.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Written by: Dr. JJ Shepherd
Comments, Conditional Statements Continued, and Loops Engineering 1D04, Teaching Session 4.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
REPETITION CONTROL STRUCTURE
Loop Structures.
Repetition-Counter control Loop
MSIS 655 Advanced Business Applications Programming
Code Coverage David Inglis November 18, 2018.
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Do … Loop Until (condition is true)
CSE 303 Concepts and Tools for Software Development
Introduction to Programming
Paul Ammann & Jeff Offutt
Software Testing.
Presentation transcript:

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 1 Tutorial / lab 2: Code instrumentation Goals of this session: 1.Create some tests for a Java class. 2.Measure the code coverage.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 2 Code Instrumentation Tools Tools that modify production code for various purposes during code execution: –Debuggers –Add information to allow for break points or step-by-step execution. –Coverage measurement –Report on the number of times various code elements have been executed. –Profilers –Measure amount of time spent in various parts of the code.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 3 Coverage tools Program is typically compiled with special options, to add extra source or object code. –Additional data structures, such as a flow graph, may also be created. Program is run, possibly via test cases –During execution, information is accumulated and written to an output file. Post-processing phase: –User report is generated from output file.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 4 How to measure coverage? Instrument the source code before compilation Instrument the virtual machine or object code. –The Apache Byte Code Engineering Library (BCEL) is used by several Java coverage tools – Use a customized virtual machine.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 5 Source code instrumentation Create a copy of the source code, instrument the copy, and compile the instrumented copy to.class files. –This is the approach used by the Clover code coverage tool. Typical method: –Set up an array of counters. –Insert source code at points of interest that increment specific counters. –Coverage tool calls main() method –After main method returns, dump values of counters.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 6 Source code before instrumentation public final void add( final MatrixRow newValues ) { if ( getNumColumns( ) == 0 ) { contents = newValues.copy( ).getContents( ); } else { contents.addAll( newValues.copy( ).getContents( ) ); } A counter is inserted for each method, statement, and branch. Statement counters are before each statement, in case the statement throws an exception. Branch counters need to identify true and false branches taken.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 7 Same code after instrumentation public final void add( final MatrixRow newValues ) { CLOVER.M[348]++; CLOVER.S[1814]++; if ( ( getNumColumns( )==0 && ++CLOVER.CT[338]!=0 | true ) || ( ++CLOVER.CF[338] == 0 & false ) ) { CLOVER.S[1815]++; contents = newValues.copy( ).getContents( ); } else { CLOVER.S[1816]++; contents.addAll( newValues.copy( ).getContents( ) ); } method counter statement counters branch counters

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 8 Counting branches Count number of times that a branch condition evaluates to true and false. if ( ( aBoolean && ++CT[338]!=0 | true ) || ( ++CF[338] == 0 & false ) ) If aBoolean is true, then the && is also evaluated, which will increment the CT counter. We want the expression’s overall evaluation to be true. If aBoolean is false, then execution switches to the right side of the || clause. Increment the CF counter, but then ensure that the entire expression still evaluates to false to take the else branch. Short-circuit evaluation means that as soon as the expression result can be determined, evaluation stops. This avoids: –Incrementing the true counter if aBoolean is false. –Incrementing the false counter if aBoolean is true.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 9 Analysis Advantages: –Results are directly mapped to source code. –If a statement throws an exception, it will be counted as having been executed. Disadvantages: –Requires keeping a second version of source code, and ensuring that original source is not over-written. –Instrumented code must not affect original code execution. –Management of.class files from compiling alternate source code. –Memory usage: for statement coverage alone, every statement requires one integer as a counter.

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 10 Byte code instrumentation Can be done in two ways: –Instrument object files in advance to produce a alternate version. –Example: create instrumented.class files for Java. –Instrument object files as they are used. –Example: create customized.class file loader that inserts the instrumentation at run time. This is the approach used by the Emma code coverage tool –This is an open-source tool; see –Eclipse plug-in version:

© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 11 Analysis Pre-instrumentation: –Advantages: –source code is not modified. –can be done as a batch process before execution –Disadvantages: –management of two.class file versions. –mapping of source code statements to/from object code –counting source code statements can be difficult –object code may need extra information such as special compiler options