Fondazione Bruno Kessler - IRST

Slides:



Advertisements
Similar presentations
Acceptance and Unit Testing (introduction)
Advertisements

Testing Relational Database
Acceptance Testing vs. Unit Testing: A Developers Perspective Owen Rogers Rob Styles
Programming Paradigms and languages
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Tutorial 8: Developing an Excel Application
Programming Types of Testing.
Chapter 7 Using Data Flow Diagrams
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
Senior Design – Acceptance Test Plan Review The goal is to: define the criteria for approving the application. Tightly coupled to the Requirements document.
Introduction to Software Testing
UNIT-V The MVC architecture and Struts Framework.
Hands on Experiment Design Foutse Khomh, Queen’s University, Canada Massimiliano Di Penta, University of Sannio, Italy.
Module 3: Table Selection
Table-Driven Acceptance Testing Mario Aquino Principal Software Engineer Object Computing, Inc.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Computer Science and Engineering College of Engineering The Ohio State University JUnit The credit for these slides goes to Professor Paul Sivilotti at.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Chapter 7 Using Data Flow Diagrams
Unit and Functional Testing Your Flex Applications Mike Nimer Dir. Of Engineering nomee.com.
Capture and Replay Often used for regression test development –Tool used to capture interactions with the system under test. –Inputs must be captured;
Winrunner Usage - Best Practices S.A.Christopher.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Exploring an Open Source Automation Framework Implementation.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Software Construction Lecture 18 Software Testing.
TEST-1 6. Testing & Refactoring. TEST-2 How we create classes? We think about what a class must do We focus on its implementation We write fields We write.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
Acceptance testing An introduction Alessandro Marchetto Fondazione Bruno Kessler - IRST.
S Ramakrishnan1 Systems V & V, Quality and Standards Dr Sita Ramakrishnan School CSSE Monash University.
JUnit A Unit Testing Framework for Java. The Objective Introduce JUnit as a tool for Unit Testing Provide information on how to: Install it Build a test.
CS451 Software Implementation and Integration Yugi Lee STB #555 (816) Note: This lecture was designed.
© 2012 LogiGear Corporation. All Rights Reserved FitNesseFitNesse Authors: Nghia Pham 1.
Test a Little, Code a Little Colin Sharples IBM Global Services New Zealand Colin Sharples IBM Global Services New Zealand.
 Software Testing Software Testing  Characteristics of Testable Software Characteristics of Testable Software  A Testing Life Cycle A Testing Life.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
CS223: Software Engineering Lecture 31: Acceptance Testing.
What is a Computer An electronic, digital device that stores and processes information. A machine that accepts input, processes it according to specified.
Northwest Arkansas.Net User Group Jay Smith Tyson Foods, Inc. Unit Testing nUnit, nUnitAsp, nUnitForms.
This was written with the assumption that workbooks would be added. Even if these are not introduced until later, the same basic ideas apply Hopefully.
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Section 10.1 Define scripting
Progress Apama Fundamentals
Software Testing.
Unit Testing.
Selenium HP Web Test Tool Training
Testing Tutorial 7.
Integration Testing.
Software Testing.
Selenium HP Web Test Tool Training
Introduction to JUnit CS 4501 / 6501 Software Testing
FIT Testing 2 December 7, 2004.
Haritha Dasari Josue Balandrano Coronel -
Applied Software Implementation & Testing
Unit 27 - Web Server Scripting
Introduction to Software Testing
Lecture 09:Software Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Introduction to JUnit IT323 – Software Engineering II
Teaching slides Chapter 6.
LESSON 01 Hands-on Training Execution
Web Development Using ASP .NET
CS 240 – Advanced Programming Concepts
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
JUnit SWE 619 Spring 2008.
Selenium IDE Installation and Use.
Unit Testing.
Presentation transcript:

Fondazione Bruno Kessler - IRST Acceptance testing An introduction Alessandro Marchetto Fondazione Bruno Kessler - IRST

Outline Introduction Acceptance and Unit testing Table-based testing and Fit/Fitnesse Fit/Fitnesse: An Example

Testing One of the practical methods commonly used to detect the presence of errors (failures) in a computer program is to test it for a set of inputs. Our program The output is correct? I1, I2, I3, …, In, … Expected results = ? Obtained results “Inputs”

Test last New functionality Understand Implement functionality The most conventional approach… New functionality Understand Implement functionality Write tests Run all tests fail Rework Result? pass Next functionality

Test first New functionality Understand Add a single test “Extreme programming” (XP) champions the use of tests as a development tool … New functionality Understand Add a single test Add code for the test Run all test fail No Rework Result? pass Functionality complete? Yes Next functionality

Test-first with Junit Add a testcase Add the skeleton of the class and methods (without body) Run test Rework Refactoring “improving the structure” Run test

Test first advantages Each method has associated a test-case the confidence of our code increases … It simplifies: refactoring restructuring maintenance the introduction of new functionalities Test first helps in writing the documentation test cases are good “use samples”

Test levels Unit testing – this is basically testing of a single function, procedure, class. Integration testing – this checks that units tested in isolation work properly when put togheter. System testing – here the emphasis is to ensure that the whole system can cope with real data, monitor system performance, test the system’s error handling and recovery routines. Acceptance testing – this check that the overall system is functioning as required

Unit Testing Unit Tests are tests written by the developers to test functionality as they write it. Each unit test typically tests only a single class, or a small cluster of classes. Unit tests are typically written using a unit testing framework, such as JUnit (automatic unit tests). Target errors not found by Unit testing: - Requirements are mis-interpreted by developer. - Modules do not integrate with each other

The tools picture GUI Business Logic Web UI Persistence Layer Jemmy/Abbot/JFCUnit/… FIT/Fitnesse (High level) GUI Perfomance and Load Testing JMeter/JUnitPerf Business Logic Cactus HttpUnit/Canoo/Selenium Junit (Low level) Cactus is an extension to JUnit that allows for the testing of server-side Java code without having to run a server external to the testing setup Web UI Persistence Layer Junit/SQLUnit/XMLUnit

Outline Introduction Acceptance and Unit testing Table-based testing and Fit/Fitnesse Fit/Fitnesse: An Example

Acceptance Testing Acceptance Tests are specified by the customer and analyst to test that the overall system is functioning as required (Do developers build the right system?). Acceptance tests typically test the entire system, or some large chunk of it. When all the acceptance tests pass for a given user story (or use case, or textual requirement), that story is considered complete. An acceptance test could consist of a script of user interface actions and expected results that a human can run. Ideally acceptance tests should be automated, either using the unit testing framework, or a separate acceptance testing framework.

Acceptance vs. Unit Testing In summary: The motivation of unit testing is finding faults. The motivation of acceptance testing is demonstrating working functionalities. Written and executed during the development. Written before the development and executed after. Written using a unit testing framework. Written using an acceptance testing framework (also unit testing framework). Starting point: new capability (to add a new module/function or class/method). …. (the unit) Starting point: User stories, User needs, Use Cases, Textual Requirements, … (the whole system) Used to find faults in individual modules or units (individual programs, functions, procedures, web pages, menus, classes, …) of source code. Used for documentation (low level) Used to verify that the implementation is complete and correct. Used for Integration, System, and regression testing. Used to indicate the progress in the development phase. (Usually as %). Used as a contract. Used for documentation (high level) (extreme programming) When unit tests pass, write another test that fails. (extreme programming) When acceptance tests pass, stop coding. The job is done. Written by developers. Written by Customer and Analyst. Unit Tests Acceptance Tests

Traditional approaches to acceptance testing Manual Acceptance testing. User exercises the system manually using his creativity. Acceptance testing with “GUI Test Drivers” (at the GUI level). These tools help the developer to do functional/acceptance testing through a user interface such as a native GUI or web interface. “Capture and Replay” Tools capture events (e.g. mouse, keyboard) in modifiable script. Disadvantages: expensive, error prone, not repeatable, … Disavantages: Tests are brittle, i.e., have to be re-captured if the GUI changes.

Outline Introduction Acceptance and Unit testing Table-based testing and Fit/Fitnesse Fit/Fitnesse: An Example

Table-based approach for acceptance Testing Starting from a user story (or use case or textual requirement), the customer enters in a table (spreadsheet application, html, Word, …) the expectations of the program’s behavior. At this point tables can be used as oracle. The customer can manually insert inputs in the System and compare outputs with expected results. inputs output Pro: help to clarify requirements, used in System testing, … Cons: expensive, error prone, …

What is Fit? The Framework for Integrated Test (Fit) is the most well-known implementation (open source framework) of the table-based acceptance testing approach. Fit lets customers and analysts write “executable” acceptance tests by means of tables written using simple HTML. Developers write “fixtures” to link the test cases with the actual system itself. Fit compares these test cases, written using HTML tables, with actual values, returned by the system, and highlights the results with colors and annotations.

The picture o ≠ o’ o’ i (i, o) System Output Table Developer Test Runner Fixture o’ i Customer/ Analyst (i, o) System User Story Fit Table O = expected output O’ = actual output

Fixture Fit provides a set of fixtures: Column fixture for testing calculations. Action fixture for testing the user interfaces or workflow. Row fixture for validating a collection of domain objects. Used to check the result of a query. Summary fixture to display a summary of all test on a page. Html fixture to examine and navigate HTML pages. Table fixture, Command line fixture, …

What is FitNesse? A collaborative testing and documentation tool: It supports Java (eclipse plug-in), .Net, C++ It combines Fit with a Wiki Web for writing “natural language requirements” + Fit tables. It provides a simple way to run tests (Fit tables) and suits. It Supports Wiki and sub Wikis for managing multiple projects.

How to use FitNesse? “expected 170, actual 190” Install and start. Define the project on the FitNesse Wiki. Write requirements and fit tables on the FitNesse Wiki. Write the glue code (fixture), the unit tests and the business logic in your favorite IDE (eclipse). Execute the acceptance tests by a click on the Web page (test button). See the results (green or red) of executing the tests on the Web page. “expected 170, actual 190”

Outline Introduction Acceptance and Unit testing Table-based testing and Fit/Fitnesse Fit/Fitnesse: An Example

An example: the Football-team Application A sports magazine decides to add a new feature to its Website that will allow users to view top football teams according to their ratings. An analyst and a developer get together to discuss the change requirements. The outcome of the discussion is: a user story card that summarizes the change requirements a set of acceptance tests an excel file with sample data

user story (change requirement) set of acceptance tests excel file with sample data

The domain object representing a football team package sport.businessObjects; public class Team { public String name; public int played; public int won; public int drawn; public int lost; public int rating; public Team(String name, int ply, int won, int drawn, int lst) { super(); this.name = name; this.played = played; this.won = won; this.drawn = drawn; this.lost = lost; calculateRating(); } private void calculateRating() { float value = ((10000f*(won*3+drawn))/(3*played))/100; rating = Math.round(value);

Test1: Fit Table “verify the rating is calculated properly” For a team, given the number of matches played, won, drawn, and lost, we need to verify that the ratings are calculated properly. The first step is to express the logic using a Fit table. The table created using Excel can be easily converted into a Fit table by just adding a fixture name and modifying the labels. The Fit table on the right represents the first acceptance test case to verify the rating calculation. Now that we have created the Fit table, we need to write the glue code that will bridge the test case to the system under test. “column fixture”

Test1: Fixture “verify the rating is calculated properly” For each input attribute represented by Columns 1 through 5 in the second row of the Fit table, there is a public member with the same name A public method public long rating() corresponds to the calculation in the sixth column. The rating() method in VerifyRating creates a Team object using the input data specified by the test case and returns the rating from the Team object; this is where the bridging between the test case and the system under test happens. public class VerifyRating extends ColumnFixture { public String teamName; public int played; public int won; public int drawn; public int lost; public long rating() { Team team = new Team(teamName, played,won,drawn,lost); return team.rating; }

Test1: Running “verify the rating is calculated properly” Here is what happens when you run the test: Fit parses the table and creates an instance of “sample.VerifyRating” For each row in the table Fit set the values specified in Columns 1 through 5 to the corresponding fields in the fixture. The rating() method is executed to get the actual value to be compared against the expected value specified in the sixth column. If the expected value matches the actual value, then the test passes; otherwise it fails. Launch the test runner … 75 5 7 26 38 Wigan 100 expected ------------------- 93 actual 2 1 35 Dummy 93 Chelsea 54 16 20 Aston Villa 83 31 Arsenal rating() lost drawn won played team name sport.fixtures.VerifyRating passed failed exception