Testing Web Applications with the Atomic Section Model

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

Cutting Edge Research in Engineering of Web Applications Part 2 What is Different about Engineering Web Apps? Jeff Offutt Professor of Software Engineering.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
UNIT-V The MVC architecture and Struts Framework.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
INTRODUCTION TO WEB DATABASE PROGRAMMING
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Testing Dynamic Aspects of Web Applications Jeff Offutt Professor, Software Engineering George Mason University Fairfax, VA USA
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
Quality Attributes of Web Software Applications – Jeff Offutt By Julia Erdman SE 510 October 8, 2003.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
Chapter 6 Server-side Programming: Java Servlets
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
12. DISTRIBUTED WEB-BASED SYSTEMS Nov SUSMITHA KOTA KRANTHI KOYA LIANG YI.
Upsorn Praphamontripong CS Design and Implementation of Software for the Web Fall 2016 State Handling on the Web.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Usability Overview Upsorn Praphamontripong CS
Web Programming Language
Paul Ammann & Jeff Offutt
Running a Forms Developer Application
Introduction to Unique Aspects of Web Applications
WWW and HTTP King Fahd University of Petroleum & Minerals
Netscape Application Server
Paul Ammann & Jeff Offutt
Scripted Page Web App Development (Java Server Pages)
Scope and State Handling in JSPs
Web Software Model CS 4640 Programming Languages for Web Applications
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
The Atomic Section Model
Distributed web based systems
AJAX.
Haritha Dasari Josue Balandrano Coronel -
AJAX.
PHP / MySQL Introduction
Migrating Oracle Forms Using Oracle Application Express
Introduction to Web Applications
Design and Maintenance of Web Applications in J2EE
The Application Lifecycle
Client side & Server side scripting
Introduction to Software Testing
Web Development Using ASP .NET
Handling State in Java Servlets
Handling State in Web Applications
JavaScript.
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Teaching slides Chapter 6.
Scope and State Handling in Java Server Pages
Back end Development CS Programming Languages for Web Applications
State Handling CS 4640 Programming Languages for Web Applications
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Error Handling in Java Servlets
Exploring DOM-Based Cross Site Attacks
Back end Development CS Programming Languages for Web Applications
State Handling CS 4640 Programming Languages for Web Applications
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

Testing Web Applications with the Atomic Section Model Jeff Offutt Professor, Software Engineering George Mason University Fairfax, VA USA www.cs.gmu.edu/~offutt/ offutt@gmu.edu Joint research with Blaine Donley, Upsorn Praphamontripong, Ye Wu

OUTLINE Motivation Unique Aspects of Web Software The Atomic Section Model Testing with the AtS Model Other Applications and Summary Linköping, January 2011 © Jeff Offutt

Software is a Skin that Surrounds Our Civilization Quote due to Dr. Mark Harman Linköping, January 2011 © Jeff Offutt

Costly Software Failures “The Economic Impacts of Inadequate Infrastructure for Software Testing” Inadequate software testing costs the US alone between $22 and $59 billion USD annually Better testing could cut this amount in half 2006 : Amazon’s BOGO offer became a double discount 2007 : Symantec says that most security vulnerabilities are now due to faulty software And more than half are in web applications Huge losses due to web application failures Financial services : $6.5 million per hour (just in USA!) Credit card sales applications : $2.4 million per hour (in USA) World-wide monetary loss due to poor software is staggering Linköping, January 2011 © Jeff Offutt

Cost Of Late Testing 60 50 40 30 20 10 Requirements Design Fault origin (%) Fault detection (%) Unit cost (X) 28-Oct-2010, at GTAC, added the animation to demonstrate increasing the number of faults found early, thereby decreasing the number of faults found late, and finally saving money. Lots of it! This animation is fairly complicated … must practice first!! Requirements Design Prog / Unit Test Integration Test System Test Production Software Engineering Institute; Carnegie Mellon University; Handbook CMU/SEI-96-HB-002 Linköping, January 2011 © Jeff Offutt

Why should I trust you enough to try again? Example Failure 1 Why should I trust you enough to try again? 11/8/2018 © Offutt

Oh yeah?? I’m definitely pushing BACK ! Example Failure 2 Oh yeah?? I’m definitely pushing BACK ! Linköping, January 2011 © Jeff Offutt

OUTLINE Motivation Unique Aspects of Web Software The Atomic Section Model Testing with the AtS Model Other Applications and Summary Linköping, January 2011 © Jeff Offutt

Software Deployment Methods Bundled : On your computer when you buy it Shrink-wrapped : Bought at a store on a CD Downloaded from company’s website or OSS site Contract : Single customer Embedded : Installed on an electronic device Web application : On the web through a URL Component-based Concurrent / distributed Users access same version on the server Can be updated at any time (fast update cycle) User interactive Linköping, January 2011 © Jeff Offutt

Server Side Processing HTTP Request data Web server UI implemented in a browser Container engine Program components Client Server HTML HTTP Response Linköping, January 2011 © Jeff Offutt

Web Software Container Engine Web App 1 Web App 2 C2a C1a C2b C1b C2d C1c C2c Shared memory Shared memory Shared memory Linköping, January 2011 © Jeff Offutt

Issues with Programming Web Apps Control flow State management and variable scope Linköping, January 2011 © Jeff Offutt

Traditional Control Flow Method / function calls Decisions – if, while, for, repeat-until, switch, … Static includes – other code pulled in before compiling OO languages Some dynamic binding via polymorphism Client / Server Message passing Linköping, January 2011 © Jeff Offutt

Web App Control Flow Same as traditional – Software on server and client Message passing : Synchronous – Client to server via HTTP Asynchronous – Client to server via Ajax Event handling – on the client Forward – Transfers control from one server component to another, no return Redirect – Ask client to send request elsewhere Operational transitions – URL rewriting, back, forward, … Dynamic include – Control passes to another component, then returns, no parameters Dynamic binding – Reflection allows new components Linköping, January 2011 © Jeff Offutt

Ramifications The traditional control flow graph does not model essential parts of web app execution ! UML diagrams do not model many of these Most developers learn the syntax, but not the concepts behind these new control connections Lots of poorly designed software … and lots and lots of poorly understood software faults ! Linköping, January 2011 © Jeff Offutt

State Management and Variable Scope HTTP is stateless Connections between clients and web servers are not maintained Each request is independent Control flow repeatedly goes through the client How can the software keep track of multiple requests from the same user ? Container engines maintain session data Linköping, January 2011 © Jeff Offutt

Sessions—Big Picture Web Server Client 1 Client 2 Time Time HTTP Request HTTP Request HTTP Response Session ID = 0347 HTTP Response Session ID = 4403 Server returns a new unique session ID when the request has none HTTP Request HTTP Request Session ID = 0347 Session ID = 4403 HTTP Response HTTP Response HTTP Request Session ID = 0347 HTTP Request Session ID = 4403 HTTP Response HTTP Response Linköping, January 2011 © Jeff Offutt

Sessions—Big Picture Web Server Client 1 Client 2 Time Time HTTP Request HTTP Request HTTP Response Session ID = 0347 HTTP Response Session ID = 4403 HTTP Request HTTP Request Session ID = 0347 Client stores the ID and sends it to the server in subsequent requests Session ID = 4403 HTTP Response HTTP Response HTTP Request Session ID = 0347 HTTP Request Session ID = 4403 Server recognizes these requests as being from a different client. Server recognizes all the requests as being from the same client. This defines a session. HTTP Response HTTP Response Linköping, January 2011 © Jeff Offutt

Sharing Data : Session Object One program component can store a value in the session object Another component can retrieve, use, and modify the value Depends on the container engine: Software components run as threads, not processes Container engine stays resident and can keep shared memory Different programs can share data through the context object Linköping, January 2011 © Jeff Offutt

Sharing Data with Scope (JSP) application session request page forward request Client 1 request request page forward Client 2 request page Linköping, January 2011 © Jeff Offutt

Control Flow and State Summary Managing state and control flow is fundamental to any program These are the most unique aspects of designing and programming web applications Software vendors are creating new frameworks all the time Most introduce additional state handling techniques Many professional web developers make fundamental mistakes with state and control ! State management is the most common source of software faults in web applications Linköping, January 2011 © Jeff Offutt

OUTLINE Motivation Unique Aspects of Web Software The Atomic Section Model Testing with the AtS Model Other Applications and Summary Linköping, January 2011 © Jeff Offutt

Control Flow Graphs in Web Applications Many testing criteria on non-Web software rely on a static control flow graph Edge testing, data flow, logic coverage … Also slicing, change impact analysis, … The potential flow of control cannot be known statically Control flow graphs cannot be computed for Web apps! But all the pieces of the web pages and programs are contained in the software source … Linköping, January 2011 © Jeff Offutt

Atomic Sections Atomic sections Empty atomic section Content variables PrintWriter out = response.getWriter(); P1 = out.println (“<HTML>”) out.println (“<HEAD><TITLE>” + title + “</TITLE></HEAD>”) out.println (“<BODY>”) title myVector.elementAt (i) Content variables Atomic sections if (isUser) { P2 = out.println (“<CENTER>Welcome!</CENTER>”); for (int i=0; i<myVector.size(); i++) if (myVector.elementAt(i).size > 10) P3 = out.println (“<P><B>” + myVector.elementAt(i) + “</B></P>”); else P4 = out.println (“<P>" + myVector.elementAt (i) + “</P>”); Empty atomic section } else P5 = { } P6 = out.println (“</BODY></HTML>”); out.close (); Linköping, January 2011 © Jeff Offutt

Atomic Sections Defined A section of HTML with the property that if any part of the section is sent to a client, the entire section is May include JavaScript All or nothing property An HTML file is an atomic section Content variable : A program variable that provides data to an atomic section Atomic sections may be empty Linköping, January 2011 © Jeff Offutt

Component Expressions Atomic sections are combined to create dynamically generated web pages Four ways to combine: Sequence : p1  p2 Selection : (p1 | p2) Iteration : p1* Aggregation : p1 {p2} p2 is included inside of p1 The previous example produces: p  p1  (p2  (p3 | p4)* | p5)  p6 Linköping, January 2011 © Jeff Offutt

Modeling Component Transitions Five types of transitions Simple Link Transition : An HTML link (<A> tag) Form Link Transition : Form submission link Component Expression Transition : Execution of a software component causes a component expression to be sent to the client Operational Transition : A transition out of the software’s control Back button, Forward button, Refresh button, User edits the URL, Browser reloads from cache Redirect Transition : Server side transition, invisible to user Linköping, January 2011 © Jeff Offutt

gradeServlet Example ID = request.getParameter ("Id"); passWord = request.getParameter ("Password"); retry = request.getParameter ("Retry"); PrintWriter out = response.getWriter(); out.println (“<HTML> <HEAD><TITLE>" + title + "</TITLE></HEAD><BODY>)" P1 = if ((Validate (ID, passWord)) { out.println (“ <B> Grade Report </B>"); P2 = for (int i = 0; i < numberOfCourses; i++) out.println(“<P><B>" + courseName (i) + "</B>“ + courseGrade (i) + “</P>”); P3 = } else if (retry < 3) { retry++; out.println ("Wrong ID or wrong password"); out.println ("<FORM Method=\“get\" Action=\"gradeServlet\">”); out.println ("<INPUT Type=\“text\" Name=\"Id\" Size=10>"); out.println ("<INPUT Type=\“password\" Name=\"Password\" Width=20>"); out.println ("<INPUT Type=\“hidden\" Name=\"Retry\" Value=" + retry + ">"); out.println ("<INPUT Type=\“submit\" Name=\“Submit\" Value=\“submit\">"); out.println ("<A Href=\"sendMail\">Send mail to the professor</A>"); P4 = } else if (retry >= 3) { out.println (“<P>Wrong ID or password, retry limit reached. Good bye.") } P5 = out.println(“</BODY></HTML>"); P6 = Linköping, January 2011 © Jeff Offutt

CIM for gradeServlet A = {p1, p2, p3, p4, p5, p6 } S = login.html A = {p1, p2, p3, p4, p5, p6 } CE = gradeServlet = p1 • ((p2 • p3* ) | p4 | p5) • p6 T = {login.html gradeServlet [get, (Id, Password, Retry)], gradeServlet.p4 sendMail [get, ()], gradeServlet.p4 gradeServlet [get, (Retry)] } Form link transition Simple link transition Linköping, January 2011 © Jeff Offutt

Application Transition Graph Finite set of web components Γ = { login.html, gradeServlet, sendMail, syllabus.html } Set of transitions among web software components Θ = { login.html syllabus.html [get, ()], login.html gradeServlet [get, (Id, Password, Retry)], gradeServlet.p4 sendMail [get, ()], gradeServlet.p4 gradeServlet [get, (Retry)] } Set of variables that define the web application state Σ = { Id, Password, Retry } Set of start pages α = { login.html } Linköping, January 2011 © Jeff Offutt

ATG for gradeServlet login.html syllabus.html gradeServlet sendMail get () get () syllabus.html get (Id, Password, Retry) get (Id, Password, Retry) gradeServlet p1 p4 p5 p6 p2 p3 sendMail get () Linköping, January 2011 © Jeff Offutt

OUTLINE Motivation Unique Aspects of Web Software The Atomic Section Model Testing with the AtS Model Other Applications and Summary Linköping, January 2011 © Jeff Offutt

Test Criteria Tests can be applied at the intra- or the inter-component level Tests are created by deriving sequences of transitions among the web software components and composite sections Linköping, January 2011 © Jeff Offutt

Composite Section Test Criteria Intra-Component All productions in the grammar Multiple forms for each software component Each atomic section used at least once Each selection used once Every form element Each possible aggregation MCDC type coverage of conditions on productions Based on predicates from the software that separate atomic sections Linköping, January 2011 © Jeff Offutt

ATG (Inter-Component) Tests L1 : Evaluate static link transitions One test generated for each form L2 : L1 with two extensions Values entered with URL rewriting Multiple tests for each form L3 : Operational transitions Starting on non-initial pages, no subsequent transitions L4 : Operational transitions L1 tests with one operational transition at end L5 : L4 + tests to traverse every transition out of the final page Linköping, January 2011 © Jeff Offutt

Empirical Evaluation Testing STIS STIS helps users keep track of arbitrary textual information 18 JSPs, 5 Java classes, database Atomic sections derived automatically Parser works on Java servlets, JSPs, Java classes ATG derived by hand Form data chosen by hand 109 total tests Linköping, January 2011 © Jeff Offutt

STIS Application Transition Graph index.jsp post (userid, password) login.jsp logout.jsp record_add.jsp browse.jsp categories.jsp post (category, search_name) post (name, category, content) post (action, categoryName) update_search_params.jsp record_insert.jsp simple link transition forward link transition form link transition Linköping, January 2011 © Jeff Offutt

Results from Testing STIS previous web tests 109 tests Failure Category L1 L2 L3 L4 L5 Number of tests 29 21 7 19 33 Pages displayed without authentication 2 4 2. Records added without authentication 1 3. Runtime failures (unhandled exceptions) 3 5 Total number of failures 11 6 Found 25 naturally occurring failures Linköping, January 2011 © Jeff Offutt

OUTLINE Motivation Unique Aspects of Web Software The Atomic Section Model Testing with the AtS Model Other Applications and Summary Linköping, January 2011 © Jeff Offutt

Atomic Sections Summary Atomic sections fundamentally model Web applications Allow the Web app form of CFGs Can also be used for Software evolution Design modeling / evaluation Change impact analysis (slicing) Coupling of Web application components Linköping, January 2011 © Jeff Offutt

Test Design Human-based test design uses knowledge of the software domain, knowledge of testing, and intuition to generate test values Criteria-based test design uses engineering principles to generate test values that cover source, design, requirements, or other software artifact A lot of test educators and researchers have taken an either / or approach – a competitive stance To test effectively and efficiently, a test organization needs to combine both approaches ! A cooperative stance. Linköping, January 2011 © Jeff Offutt

Advantages of Criteria-Based Test Design Criteria maximize the “bang for the buck” Fewer tests that are more effective at finding faults Comprehensive test set with minimal overlap Traceability from software artifacts to tests The “why” for each test is answered Built-in support for regression testing A “stopping rule” for testing—advance knowledge of how many tests are needed Natural to automate Linköping, January 2011 © Jeff Offutt

Conclusions The Web provides a new way to deploy software The new technologies means that old testing techniques do not work very well New tools and techniques are being developed Most are still in the research stage Most companies test web software very badly Linköping, January 2011 © Jeff Offutt

References and Contact Modeling Presentation Layers of Web Applications for Testing, Jeff Offutt and Ye Wu, Springer’s Software and Systems Modeling, 9(2), April 2010 Applying Mutation Testing to Web Applications, Upsorn Praphamontripong and Jeff Offutt. Sixth Workshop on Mutation Analysis (Mutation 2010), April 2010, Paris,France Testing Web Applications by Modeling with FSMs, Anneliese Andrews, Jeff Offutt and Roger Alexander, Springer’s Software Systems and Modeling, 4(3):326- 345, July 2005 Quality Attributes of Web Software Applications, Jeff Offutt, IEEE Software: Special Issue on Software Engineering of Internet Software, March/April 2002 Jeff Offutt offutt@gmu.edu http://cs.gmu.edu/~offutt/ Linköping, January 2011 © Jeff Offutt