1 Unit Testing for Domain-Specific Languages 1 Hui Wu, 1 Jeff Gray and 2 Marjan Mernik 1 University of Alabama at Birmingham, USA

Slides:



Advertisements
Similar presentations
Vilmos Zsombori , Shanghai
Advertisements

ANTLR in SSP Xingzhong Xu Hong Man Aug Outline ANTLR Abstract Syntax Tree Code Equivalence (Code Re-hosting) Future Work.
© Chinese University, CSE Dept. Software Engineering / Software Engineering Topic 1: Software Engineering: A Preview Your Name: ____________________.
DSLs: The Good, the Bad, and the Ugly Kathleen Fisher AT&T Labs Research.
This research is supported by NSF CAREER award CCF A Demonstration-based Approach to Support Live Transformations in a Model Editor Yu SunUniversity.
Building Enterprise Applications Using Visual Studio ®.NET Enterprise Architect.
Automated Analysis and Code Generation for Domain-Specific Models George Edwards Center for Systems and Software Engineering University of Southern California.
Software Reuse Building software from reusable components Objectives
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
Reasons to study concepts of PL
Programming Languages Structure
A Domain-specific Modeling Approach to the Development of Online Peer Assessment Yongwu Miao and Rob Koper Educational Technology Expertise Centre Open.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Whole Platform Tesi di Dottorato di: RICCARDO SOLMI Università degli Studi di Bologna Facoltà di scienze matematiche, fisiche e naturali Corso di Dottorato.
Mining Metamodels From Instance Models: The MARS System Faizan Javed Department of Computer & Information Sciences, University of Alabama at Birmingham.
© 2008 IBM Corporation Behavioral Models for Software Development Andrei Kirshin, Dolev Dotan, Alan Hartman January 2008.
Miser-C MISRA-C Compliance Checker Ian Biller, Phillippe Dass, Bryan Eldridge, Jon Senchyna, Tracy Thomas Faculty Coach: Professor Michael Lutz Project.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Building Applications.
Your Interactive Guide to the Digital World Discovering Computers 2012.
Spectra Software Defined Radio Products Applying Model Driven Design, Generative Programming, and Agile Software Techniques to the SDR Domain OOPSLA '05.
Introduction to High-Level Language Programming
Introduction 01_intro.ppt
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
A Generative and Model Driven Framework for Automated Software Product Generation Wei Zhao Advisor: Dr. Barrett Bryant Computer and Information Sciences.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Yu SunUniversity of Alabama at Birmingham PAR Works Jeff Gray University of Alabama Montpellier, France July 3rd, 2013 This research is supported.
Yu Sun 1, Zekai Demirezen 1, Marjan Mernik 2, Jeff Gray 1, Barret Bryant 1 1 Department of Computer and Information Sciences, University of Alabama at.
1 Grammar-Driven Generation of Domain-Specific Language Testing Tools Using Aspects Ph.D. Defense Hui Wu 10/29/2007.
Supporting Heterogeneous Users in Collaborative Virtual Environments using AOP CoopIS 2001 September 5-7, Trento, Italy M. Pinto, M. Amor, L. Fuentes,
Key Challenges for Modeling Language Creation by Demonstration Hyun Cho, Jeff Gray Department of Computer Science University of Alabama Jules White Bradley.
Integrated Development Environment for Policies Anjali B Shah Department of Computer Science and Electrical Engineering University of Maryland Baltimore.
Unit Testing for Domain-Specific Languages 1 Hui Wu, 1 Jeff Gray and 2 Marjan Mernik 1 University of Alabama at Birmingham, USA
Hyper/J and Concern Manipulation Environment. The need for AOSD tools and development environment AOSD requires a variety of tools Life cycle – support.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Selected Topics in Software Engineering - Distributed Software Development.
Illustrations and Answers for TDT4252 exam, June
Contact Profile (1/2) Yu Sun, University of Alabama at Birmingham Hyun Cho, University of Alabama Jeff Gray, University of Alabama Jules White, Virginia.
OOPSLA workshop on Domain-Specific Visual Languages 1 Framework for Domain-Specific Visual Languages Juha-Pekka.
December 4, ICSSEA’03 The SmartTools Software Factory The MDA approach and Generative programming for Software Development:
Semantics for DSL Group Members: Ritu Arora, Diyang Chu, Zekai Demirezen, Jeff Gray, Jacob Gulotta, Luis Pedro, Arturo Sanchez, Greg Sullivan,Ximing Yu.
Celluloid An interactive media sequencing language.
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,
1 Model-based Aspect Weaver Construction Suman Roychoudhury Frédéric Jouault Jeff Gray {roychous, jouault, cis.uab.edu This project is supported.
DrJava A lightweight pedagogic environment for Java Eric Allen, Robert Cartwright, and Brian Stoler Rice University
Gordana Rakić, Zoran Budimac
Domain Specific Models John D. McGregor M13S1. Tool development Eclipse is an environment intended as a basis for building software engineering tools.
OOPSLA workshop on Domain-Specific Visual Languages 1 Juha-Pekka Tolvanen, Steven Kelly, Jeff Gray, Kalle Lyytinen.
 Programming - the process of creating computer programs.
Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute.
August 2003 At A Glance The IRC is a platform independent, extensible, and adaptive framework that provides robust, interactive, and distributed control.
May08-21 Model-Based Software Development Kevin Korslund Daniel De Graaf Cory Kleinheksel Benjamin Miller Client – Rockwell Collins Faculty Advisor – Dr.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
DS(M)Ls for End-Users and Domain Experts? Panel on Creating DSLs Models in Software Engineering Workshop Zurich, Switzerland June 3, 2012 Jeff Gray University.
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
A Model Transformation Approach to Automated Model Construction and Evolution Yuehua Lin Jeff Gray Department of.
1 Extending the Eclipse Debug Perspective and JUnit to Support Testing and Debugging of Domain-Specific Languages August 16, 2005 Hui Wu and Jeff Gray.
The Importance of Concrete Syntax to Support End-User Abstractions Jeff Gray University of Alabama at Birmingham ICSE MiSE Workshop Minneapolis, MN May.
DSLs: The Good, the Bad, and the Ugly Marjan Mernik University of Maribor Faculty of Electrical Engineering and Computer Science.
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Model Transformation By Demonstration Yu Sun, Jules White, Jeff Gray This work funded in part by NSF CAREER award CCF CIS Dept. – University of.
AUTOMATIC GENERATION OF MODEL TRAVERSALS FROM METAMODEL DEFINITIONS Authors: Tomaž Lukman, Marjan Mernik, Zekai Demirezen, Barrett Bryant, Jeff Gray ACM.
A Framework for Automated and Composable Testing of Component-based Services Miguel A. Jiménez, Ángela Villota, Norha M. Villegas, Gabriel Tamura, Laurence.
Sung-Dong Kim Dept. of Computer Engineering, Hansung University Chapter 3 Programming Tools.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Aspect-oriented Code Generation Approaches Abid Mehmood & Dayang N. A. Jawawi Department of Software Engineering Faculty of Computer Science and Information.
M&CML: A Monitoring & Control Specification Modeling Language
User Interface Design The Golden Rules: Place the user in control.
Software Architecture & Design
Presentation transcript:

1 Unit Testing for Domain-Specific Languages 1 Hui Wu, 1 Jeff Gray and 2 Marjan Mernik 1 University of Alabama at Birmingham, USA 2 University of Maribor, Slovenia IFIP DSL WC’09 Oxford England July 2009

2 The Benefits of Using DSLs Case studies and empirical evaluations documented in the research literature have identified the following benefits of DSLs –DSLs can hide the lower level programming language details from end-user programmers –DSLs assist in software maintenance whereby end- users can directly use the DSLs to make required routine modifications –DSLs assist end-users in writing more concise, descriptive, and platform independent programs –The use of DSLs increases flexibility, productivity, reliability, and usability; shorten the application development time and reduce the development cost significantly

33 Motivation of Proposed Research Domain Experts program at DSL level DSL translated into General Purpose Language (GPL) Domain Experts deal with DSL Integrated Development Environment (IDE) Editor Compiler Visualizer Debugger Domain Experts deal with GPL Test Engine Profiler

44 Mismatch Between Abstraction Levels …. commands : ( c:command cs:commands | ) ; command : ( RIGHT { fileio.print("//move right"); fileio.print("x=x+1;"); fileio.print("time=time+1;"); fileio.print(" "); } |LEFT { fileio.print("//move left"); fileio.print("x=x-1;"); fileio.print("time=time+1;"); fileio.print(" "); … …. public final void commands() throws RecognitionException, TokenStreamException { try { // for error handling { switch ( LA(1)) { case CALL: case INIT: case SET: case PRINT: { command(); commands(); break; } case END: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); … public final void function_name() throws RecognitionException, TokenStreamException { try { // for error handling { switch ( LA(1)) { case RIGHT: { match(RIGHT); fileio.print("//move right"); fileio.print("move_right();"); fileio.print(" "); break; } case LEFT: { match(LEFT); sllinenumber=dsllinenumber+1; fileio.print("//move left"); fileio.print("move_left();"); fileio.print(" "); break; } … ANTLR Grammar Generated Java Parser Code

55 Categories of Domain-Specific Languages Imperative DSL –Robot DSL Declarative DSL –Feature Description Language (FDL) –Backus–Naur Form (BNF) language syntax specification Hybrid DSL (for future work) –Swing User-interface Language (SWUL) –Hybrid Robot DSL

66 Categories of Domain-Specific Languages Imperative DSL: Centered around assignment expressions or control flow statements –Robot Language … 17 Down: 18 position(+0,-1) 19 Down: … 21 Init position(0,0) 22 Call left 23 Call down 24 Call knight 25 Set position(5,6) 26 Call up 27 Call right 28 Print position …

77 Declarative DSL: declares the relationship between inputs and outputs –Feature Description Language (FDL) 1 Car : all (Carbody, Transmission, Engine, Horsepower, opt(pullsTrailer)) 2 Transmission : oneof (automatic, manual) 3 Engine : moreof (electric, gasoline) 4 Horsepower : oneof (lowPower, mediumPower, highPower) 5 include pullsTrailer 6 pullsTrailer requires highPower Categories of Domain-Specific Languages – Backus–Naur Form (BNF) language syntax specification: a set of derivation rules START ::= begin COMMANDS end ; COMMANDS :: = COMMAND COMMANDS | epsilon ; COMMAND :: = left | right | up | down ;

88 Eclipse Plug-In Based Software Development JUnit Eclipse Plug-in

99 Plug-In Based Software Development Syntax-Directed Translation Aspect-Oriented Programming on DSL Grammars Overview of the Approach Design Patterns Generative Programming Eclipse Model-View-Controller Adapter Pattern AspectG ANTLR pointcut productions(): within(command.*); before(): productions() { dsllinenumber=dsllinenumber+1;} … public class Robot{ … x=0; y=0; time=0; //move left move_left();

10 DSL Application Software Errors! Before locating software errors how do we know there are bugs inside a DSL application?

11 DSL Unit Testing Framework (DUTF) Complement to the DSL Debug Framework (DDF) – the DUTF assists in identifying the presence of errors and the DDF assists in isolating the specific location of the error Architecture and process of construction is similar to the DDF architecture

12 DSL Unit Testing Framework (DUTF)

13 Source Code Mapping … 3 knight: 4 position(+0,+1); 5 position(+0,+1); 6 position(+1,+0); 7 knight: 8 … 9 Init position(0,0); 10 left; 11 down; 12 knight; 13 Set position(5,6); 14 up; 15 right; 16 Print position; … 6 public static void move_knight(){ 7x=x+0; 8y=y+1; 9x=x+0; 10y=y+1; 11x=x+1; 12y=y+0;} 13 public static void main(String[] args) { 14x=0; 15y=0; … 18move_knight(); … 20x = 5; 21y = 6; … 26System.out.println("x coordinate="+x+""+ 27 "y coordinate= " + y);} … {13, "Robot.java", 20, 21, "main", "none"}

14 DSL Unit Testing Framework (DUTF) Test Cases Mapping Robot DSL Unit Test Case 1 TestCase testknight { 2 Init position(0,0); 3 Expectedposition(1,2); 4 knight; 5 AssertEqual (Expectedposition, position); 6 } … GPL Unit Test Case (JUnit) 11 public void testkinght() { 12robot.x = 0; 13robot.y =0; 14int x=1; 15int y=2; 16robot.move_knight(); 17assertEquals(x, robot.x); 18assertEquals(y, robot.y); 19 } … {1, “TestRobot.java”,11,“testknight”}

15 DSL Unit Testing Framework (DUTF) Test Cases Mapping Car FDL Unit Test Case 1 TestCase testFeatures { 2 Expectedfeature:(carbody, manual, highPower); 3 use Car.FDL(All); 4 Constraint C1: include pullsTrailer; 5 AssertTrue(contain(Expectedfeature, feature)); 6 AssertEqual(6, numberof feature); 7 } GPL Unit Test Case (JUnit) 11 public void testFeatures () { 12 testFeatures.add("carbody"); 13 testFeatures.add("manual"); 14 testFeatures.add("highPower"); … 27 assertTrue(compareFeatures(testFeatures,parse(fc,root,cons))); 28 assertEquals(6,getFeatureListNumber(parse(fc,root,cons))); …

16 DSL Unit Testing Framework (DUTF) Robot Language Unit Test Engine Correct knight method 1 begin knight: 2 position (+0,+1); 3 position (+0,+1); 4 position (+1,+0); 5 end knight: Incorrect knight method 1 begin knight: 2 position (+0,+1); 3 position (+1,+1); 4 position (+1,+0); 5 end knight:

17 DSL Unit Testing Framework (DUTF) FDL Unit Test Engine

18 Lessons Learned and Limitations The concept of comparing raw values may not be relevant at the DSL level Among 22 software components in DUTF, there are 3,001 lines of code that are generalized and reused to generate the different DSL unit test engines. More complex and feature-rich DSLs will likely require additional customization DSL CategoryDSL NameNumber of Specific Functions or Classes Customized Lines of Code Imperative DSLRobot Language2239 Declarative DSLFDL4482

19 Future Work An extension of the current framework that enables DSL profiling Investigation into the scalable, reliable, and extensible DSL Unit Test framework –Application of different IDE platforms (Microsoft Visual Studio.Net) and GPLs (C# and C++) –Adaptation of DUTF to address more complex DSLs (Embedded DSLs)

20 Related Works in the Area of DSL Tools The End-Users Shaping Effective Software ( EUSES ) –Represents collaboration among several dozen researchers who aim to improve the software development capabilities provided to end-users. ASF+SDF –Generate program analysis and transformation tools, and produce software renovation tools –The unit testing tool support has not been reported JTS –Complicated mechanism (e.g., Language extension) –Does not focus on language tools generation LISA –Can generate editor, parser, and visualizer for new languages –Debugger, test engine, and profiler are not the target language tools, LISA can be used as the front-end of our framework SmartTools –Base on Java and XML technologies –Debugger, test engine, and profiler are not target language tools Other Related Testing Tools –Parameterized unit testing –Testing grammar-driven functionality –Generating unit tests using symbolic execution –Generating test inputs of AspectJ programs

21 Questions? Video demonstrations and papers available at: Acknowledgement: The work presented in this paper was supported in part by NSF CAREER grant (CCF ) and the IBM Eclipse Innovation Grant (EIG).

22 Backup Slides

23 Categories of DSL End-Users Admin Assistants Business Person Auto Factory Worker Scientist Spreadsheet Business Query Systems Modeling Language DSL for Physics

24 JUnit and NUnit Basic Unit Test Actions Comparison Unit Test ActionsJUnit (Java)NUnit (.Net languages) Equality Assertion assertEquals (expected, actual) Assert.AreEqual (expected, actual); Condition Test assertTrue(actual)Assert.IsTrue(actual) assertFalse(actual)Assert.IsFalse(actual) assertNull(actual)Assert.IsNull(actual) Utility Method fail()Assert.Fail() Identity Assert assertSame (expected, actual) Assert.AreSame (expected, actual)