JAOUT: Automated Generation of Aspect Oriented Unit Test Guoqing Xu, Z. Yang, H. Huang, Q. Chen, L. Chen and F. Xu Software Engineering Lab (SEL) East.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Automated Evaluation of Runtime Object States Against Model-Level States for State-Based Test Execution Frank(Weifeng) Xu, Gannon University Dianxiang.
Korat Automated Testing Based on Java Predicates Chandrasekhar Boyapati, Sarfraz Khurshid, Darko Marinov MIT ISSTA 2002 Rome, Italy.
Semantics Static semantics Dynamic semantics attribute grammars
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization.
JMLAutoTest and Its Double- phase Testing Way Guoqing Xu Com Sci., East China Normal Univ. Shanghai , PRC FATES 2003, Montreal, Canada, Oct.6th 2003.
Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Statistical Debugging: A Tutorial Steven C.H. Hoi Acknowledgement: Some slides in this tutorial were borrowed from Chao Liu at UIUC.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Writing a Unit test Using JUnit At the top of the file include: import junit.framework.TestCase; The main class of the file must be: public Must extend.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Chair of Software Engineering Automatic Verification of Computer Programs.
1/23/2003University of Virginia1 Korat: Automated Testing Based on Java Predicates CS751 Presentation by Radu Stoleru C.Boyapaty, S.Khurshid, D.Marinov.
Korat: Automated Testing Based on Java Predicates Chandrasekhar Boyapati 1, Sarfraz Khurshid 2, and Darko Marinov 3 1 University of Michigan Ann Arbor.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Computer Science and Engineering College of Engineering The Ohio State University JUnit The credit for these slides goes to Professor Paul Sivilotti at.
A Safety-Critical Java Technology Compatibility Kit Hans Søndergaard Stephan Korsholm VIA University College, Horsens, Denmark & Anders P. Ravn Aalborg.
VERIFICATION OF ASPECT ORIENTED MODELS BY DON MARTIN JAYASHREE VENKIPURAM PATHANGI PIYUSH SRIVASTAVA REFERENCES F. Mostefaoui and J. Vachon,” Design level.
nd Joint Workshop between Security Research Labs in JAPAN and KOREA Profile-based Web Application Security System Kyungtae Kim High Performance.
CSE 219 Computer Science III Testing. Testing vs. Debugging Testing: Create and use scenarios which reveal incorrect behaviors –Design of test cases:
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
A Novel Approach to Unit Test: The Aspect-Oriented Way Guoqing Xu and Zongyuan Yang Software Engineering Lab (SEL) East China Normal University
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
VERIFICATION OF ASPECT-ORIENTED MODELS Review of Aspect-Oriented Definitions aspect – crosscutting concern that may involve multiple classes pointcut –
JCMP: Linking Architecture with Component Building Guoqing Xu, Zongyuan Yang and Haitao Huang Software Engineering Lab, East China Normal University SACT-01,
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
1.  Writing snippets of code that try to use methods (functions) from your program.  Each snippet should test one (and only one) function......by calling.
CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
Cs2220: Engineering Software Class 6: Defensive Programming Fall 2010 University of Virginia David Evans.
CCC: An Aspect-Oriented Intermediate Language on.Net Platform Yingfei Xiong and Feng Wan University of Electronic Science and Technology of China, China.
AspectWrapper CHALFOUN Pierre et BUIST Éric. Overview Introduction – what and why In a nutshell – main components Our approach – how we did it Demo –
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
Facilitating testing and monitoring of number entry systems in medical devices Abigail Cauchi, Christian Colombo, Mark Micallef & Gordon Pace.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
( = “unknown yet”) Our novel symbolic execution framework: - extends model checking to programs that have complex inputs with unbounded (very large) data.
Whole Test Suite Generation. Abstract Not all bugs lead to program crashes, and not always is there a formal specification to check the correctness of.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
Separating Test Execution from Test Analysis StarEast 2011 Jacques Durand (Fujitsu America, Inc.) 1.
Random Test Generation of Unit Tests: Randoop Experience
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Unit Testing with JUnit
Introduction to JUnit CS 4501 / 6501 Software Testing
Input Space Partition Testing CS 4501 / 6501 Software Testing
Formally Specified Monitoring of Temporal Properties
Eclat: Automatic Generation and Classification of Test Inputs
Testing and Test-Driven Development CSC 4700 Software Engineering
Programming Languages 2nd edition Tucker and Noonan
Introduction to JUnit IT323 – Software Engineering II
Test Driven Development
Test Driven Development
Programming Languages 2nd edition Tucker and Noonan
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

JAOUT: Automated Generation of Aspect Oriented Unit Test Guoqing Xu, Z. Yang, H. Huang, Q. Chen, L. Chen and F. Xu Software Engineering Lab (SEL) East China Normal University APSEC ’ 04, Dec. 2 nd 2004, Pusan, Korea

Background Test Oracle problem -- how to identify oracles in unit test? Automating the test oracle generation -- Manually writing test codes is a labor-intensive job. -- JMLUnit framework [CL02]. Automating the test case generation -- Korat. [BKM02] -- JMLAutoTest [XY03]

Problems Current test automating process relies on formal assertions and predicts. Conventional specifications only focus on programs ’ functional behaviors, with little support for specifying their non-functional behaviors, e.g. temporal logic, performance... How to find a common approach to identifying oracles for testing non-functional aspects? How to automate this process?

Our approach Using a crosscutting property of the program as the criterion to check the correctness of the application in the corresponding aspect is well suited to the unit testing problems. -- In AOP crosscutting properties are used to model the program from different aspects. -- Some problems which have been difficult to handle in conventional ways are solved easily.

Application-specific Aspect A new notion: application-specific aspects (ASS) -- top-level application related aspects. -- established at the design level. -- may be picked up from low language level aspects. -- all the ASS for the same application share some common features, e.g. testing ASS, tracing ASS may be translated into language level aspects.

Aspect-Oriented Test Description Language How to describe ASS? -- a formal way is needed. -- can not be too complicated. Aspect-Oriented Test Description Language(AOTDL) -- used by the designer at design level -- can be translated into AspectJ aspects. Basic units in AOTDL -- Utility unit -- MeaninglessCase Advice unit -- Error Advice unit advicetype (arguments): pointcuts: conditions: message

AOTDL (cond.) Class Stack{ public void init(){...} public void push ( Node n){...}... } TestingAspect tempLogic{ Utility{ protected boolean isInitialized = false; //push is reached pointcut pushReached(Stack st): target(st)&&call(void Stack.push(Integer)); //init is reached pointcut initReached(Stack st): target(st)&&call(void Stack.init(void)); // after advice after(Stack st):initReached (st){ isInitialized = true; }

AOTDL (cond.) MeaninglessCase Advice{ /*advices for specifying criteria of meaningless test cases */ before(Stack s) : pushReached(s) : s.getSize() >=MAX : ” Overflo w ” ;... } Error Advice{ /*advices for specifying criteria of test errors */ before(Stack s): pushReached(s): ! isInitialized : ” Not Initialized ” ;... }

AOTDL (cond.) //error advices before(Stack s) throws TestErrorException: pushReached(s){ if (!isInitialized){ TestErrorException ex =new TestErrorException( “ Not Initialized ” ); ex.setSource( “ TempLogic ” ); throw ex; }

JAOUT Framework Overview

JAOUT: Automated Generation of AO Testing Framework JAOUT takes Java class M.java as the input, and automatically generate JUnit test framework. -- Aspect_M_Test.java, the JUnit unit test class. -- Aspect_M_TestCase.java, the test case provider. -- Aspect_M_TestClient.java, JMLAutoTest test case generation class.

Test Framework Definition For class C and its method M(A1 a1, A2 a2 … An an), the generated test suite is defined as --- C[ ] receivers -- A1[ ] vA1;... ; An[ ] vAn; There is a corresponding init_Ai method for each type Ai and a method init_receiver in test case provider to initialize test cases. Testers use APIs provided by JMLAutoTest to generate test case space in test client, and pass it to the test case provider.

Generated Test Method public void testM(){ for (int i0 = 0; io < receiver.length; i0++){ for (int i1 = 0; i1 < a1.length; i1++){ … try { receiver[i0].M(a1[i1], : : :, an[in]); } catch (MeaninglessCaseException e) { /*... tell framework test case was meaningless... */ continue; } catch (TestErrorException e) { String msg = e.getSource(); fail(msg + NEW LINE + e.getMessage()); } catch (java.lang.Throwable e) { continue; } finally { setUp(); // restore test cases }

Test Result...in push false F Time: 0.06 There was 1 failure: 1) testPush (sample.Stack_Aspect_TestCase)junit.framework.AssertionFailedError: In Testing Aspect TempLogic: Not Initilized! at ample.Stack_Aspect_Test.testPush (Stack_Aspect_Test.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at sample.Stack_Aspect_Test.run(Stack_Aspect_Test.java:26) at sample.Stack_Aspect_TestCase.main (Stack_Aspect_TestCase.java:24) FAILURES!!! Tests run: 3, Failures: 1, Errors: 0, Meaningless:0

Double-phase Testing A large number of meaningless test inputs in the generated test case space. It is a waste of time running programs with meaningless inputs. The effectiveness of test results are compromised if the test is exercised with too many meaningless cases.

Double-phase Testing (Cond.) Goals: 1. Prevent meaningless test cases being processed in the final test, and therefore save the time. 2. Do not require testers to know the details of the program to be tested.

Double-phase Testing (cond.) Steps 1. Establish Operational Profile 2. The first phase test (pre-test) 3. The second phase test (final test) Methods 1. Do the statistics based test cases selection. 2. Use the pre-test as the cost for reducing the number of meaningless cases in the final test.

Working Sequence

Operational Profile Operational Profile is the criterion made by the tester to divide the generated test case space into several partitions. the validity of double-phase testing relies on the quality of the operational profile. it is a good idea to start out with several models and evaluate their predictive accuracy before settling on one.

The first phase Take a relatively small number (e.g. 10%) of test cases out from each partition according to the average distribution. Run these groups of cases respectively. Make statistics on the number of meaningless test cases appeared in each group.

The second phase Calculate and determine the probability of meaningless test cases existing in each partition. Reorganize the test cases according to the inverse proportion of meaningless cases in each partition. (e.g. take 80% of cases from the partition which produces 20% of meaningless ones in the first phase.) Run the final test.

Experimental results A sample class public class BinaryTree{ public Node root; protected int size; public int getSize() { … } public JMLObjectSequence toObjectSet() { … } … } public class Node{ public Node left; public Node right; public int ID; } BinaryTree findSubTree(BinaryTree parentTree, Node thisNode)

Testing ASS MeaninglessCase Advice{ before(BinaryTree t) : MethodReached(t) : parentTree==null || thisNode ==null || (forall Node n; parentTree.toObjectSet().has(n); n.ID != thisNode.ID) } }

Test case generation We use JMLAutoTest to generate the test case space of type BinaryTree with a few nodes (five through eight). We also generate the case space of type Node. It contains 12 nodes whose IDs are from 0 to 11.

Divide the test case space For the test case space of type BinaryTree, we do not divide it and leave it as the only partition. For the space of type Node, We divide it into two partitions. The first one contains nodes whose ID varies from 0 to 5 and the second one contains the rest.

A Comparison nodes in binary tree meaningful /total in final test time in the first phase (s) total time of the test (s) meaningful /total in final test time in the first phas e (s) total time of the test (s) 5410/ / / / / / / / Double-phase way Conventional way

Related Work (Spec-based test) TestEra – Automating OO test generation. [MK01] Mulsaw project, MIT JMLUnit – Generating test oracles from JML runtime assertions. [CL02] Iowa State Univ. Korat – Generating test case based on Java predicts. [BKM02] Mulsaw project, MIT. JMLAutoTest – Generating test framework from JML runtime assertions and test cases based on class invariants. [XY03] SEL, ECNU. Jov -- java automated unit test based on inferred program properties. [XN03] Univ. of Washington.

Conclusions Traditional formal predicts do not deal with non- functional properties of the program. AOP is well suited to the unit test problems. Designers use AOTDL to build Application-Specific Testing Aspects. JAOUT translates Testing Aspects to AspectJ aspects automatically. JAOUT automatically generates JUnit test framework and uses the runtime messages thrown by Testing ASS as test oracles. JAOUT uses double-phase testing approach to filtering out meaningless cases.

Thank you … Questions?