SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
ISSN 1866-5705 		             www.testingexperience.com		   free digital version		   print version 8,00 €	   printed in Germany
                                                                                                                                                                                           8




                            Standards –
                            What about it?
                                                                                                                                  The Magazine for Professional Testers
                                                                                                                                                                          December, 2009




© iStockphoto.com/belknap
© iStockphoto.com/aabejon




                           Functional tests with the FEST framework
                                                                                                                                    by Dominik Dary



This article describes an easy and quick                  (e.g. FitNesse) is used for user acceptance           tant for whom the application is designed.
way to write robust and compact tests for                 tests in which the tests are written using            If the application is developed for experts
Swing-rich applications using the open                    simple tables in html files. Each line                with a lot of specialized views and with
source framework FEST.                                    represents an interaction with the GUI                a number of extended and self-developed
                                                          through a command like “enter text”. The              GUI components, a technical framework
In most projects a lot of time is used for testing
                                                          columns are used for commands, con-                   is much more flexible.
the application with unit tests and functional
                                                          text, selector, arguments and comments.
Graphical User Interface (GUI) tests, which                                                              •	     From a technical perspective, the usage
                                                          GUI components are identified inside the
makes the entire system safer and more robust.                                                                  of a technical framework with a well-
                                                          GUI-Dialog by their unique name. This
Most of these functional tests are often done                                                                   defined API offers the possibility to use
                                                          simple approach can be used by testers
manually, which is very time consuming.                                                                         code editors, in which the syntax is high-
                                                          without IT background and adds a layer
                                                                                                                lighted and typing errors are displayed.
Automated GUI tests can be used for verify-               of abstraction onto writing automated
                                                                                                                These editors offer code completion,
ing the main scenarios of the application. GUI            tests.
                                                                                                                refactoring, debugging and integration of
testing is also essential during application
                                                     •	   Technical Frameworks: These tests are                 various version control systems, so that
maintenance; with automated tests, the impact
                                                          written in traditional programming lan-               the history of the test file can be compared
of refactorings can be tested within minutes.
                                                          guages like Java or Ruby. Components                  to each version. Another advantage is the
The aspect of visualizing the GUI components
                                                          are also identified by the name of the                power of the programming language (e.g.
is not the main intent of this test approach.
                                                          component or more complex component                   all features of the Java language can be
Test frameworks should provide a solid way                lookups. The biggest disadvantage of this             used) and the fact that existing utility
of finding GUI components, to get robust tests            approach is the required basic know-how               classes can be reused. The biggest disad-
that are also able to run after layout changes.           about software development and the time               vantage is the necessary Java know-how
An intuitive and well-documented test frame-              needed to learn the – in some cases cryp-             of the testers.
work is important for the readability of the              tic – technical framework Application
                                                                                                         But what does a well-defined API mean? Eric
written tests and allows the tester a more rapid          Programming Interface (API).
                                                                                                         Evans and Martin Fowler invented the term of
learning.
                                                     A very important criteria for selecting a test      “fluent interface”, which is a design principle
Those functional tests describe scenarios. In-       framework is its maintainability and the dura-      for an object-oriented API with the objective
side a task manager application, a test scenario     tion of the training period. Capture and replay     to offer a more readable code that is only used
can be e.g. the entering of new to do items.         tools are at first glance an easy and fast way to   within a limited scope (e.g. functional GUI
This process includes several steps, such as         create test scripts. But these scripts are error-   testing)1. A special characteristic of this design
opening the new task form, entering some val-        prone, especially if the layout of the applica-     is the return value of a method call, which en-
ues into the text fields and clicking the “cre-      tion has changed.                                   ables to build a method chain of a class.
ate” button. Afterwards the created task must
                                                     Keyword-driven testing enables domain ex-           A sample code can look like this:
be verified. This can be done using the GUI,
                                                     perts to use this approach, because of the
e.g. by loading the task form, or directly in the                                                             dialog.botton(“login”).click();
                                                     simplicity of the test case specification. These
database to assert the entered values are saved
                                                     tests can be created with editors like Word, and
correctly.                                                                                               In this code sample, the login button is resolved
                                                     there’s a basic concept of modularization. Be-
                                                                                                         by its name and afterwards a click event is dis-
The tools employed in GUI test automation            low these frameworks, technical frameworks
                                                                                                         patched to it. This type of API is a so-called
can be categorized as follows:                       like JFCUnit are used.
                                                                                                         fluent interface, which offers the developers
•	   Capture and Replay: Testers click on            If keyword-driven testing simplifies the usage      the possibility to enhance an API to a domain-
     the test scenarios and thereafter the test      of technical frameworks, why should a team          specific language (DSL). A DSL is commonly
     framework captures all GUI interactions,        decide to use a technical framework?                described as a computer language targeted at a
     which are stored in a script that can be                                                            particular kind of problem and not intended to
                                                     This question can be answered from a domain
     replayed automatically.
                                                     view and a technical view:
•	   Keyword-driven testing: This approach                                                               1	         http://www.martinfowler.com/bliki/Flu-
                                                     •	   From a domain perspective, it is impor-
                                                                                                         entInterface.html


82                 The Magazine for Professional Testers                                                                     www.testingexperience.com
solve problems outside of its domain.2                    other modules can be       Sample test code using the FEST API
                                                          optionally used and
                                                                                     //Fill in parameters
 FEST Framework                                           are not described in
                                                                                     window.textBox(“firstNumberInput”).enterText(“22”);
 Open Source Library for GUI Testing                      this article.
                                                                                     window.textBox(“secondNumberInput”).enterText(“2”);
 •	 Supports functional Swing GUI test-                   (See Figure 1)
     ing                                                                             //Select action
 •	 Website: http://fest.easytesting.org            The Swing module is           window.radioButton(“sumRadioButton”).check();
 •	 Its API provides a fluent interface             divided into different        //Calculate
 •	 Open Source project (Apache 2.0                 layers. “Basic ro-            window.button(“calculateButton”).click();

     license)                                       bot” is the basic layer
                                                    of the FEST-Swing             //Validate the result
 •	 Supports both TestNG and JUnit                                                window.textBox(“resultOutput”).requireText(“24”);
                                                    module. The class
 •	 Simplifies troubleshooting GUI test
                                                    java.awt.Robot ,        6
     failures                                                                                            finders that can be used.
                                                    which is part of the Java Development Kit
 •	 Hosted at CodeHaus
                                                    (JDK), is the main component of FEST-Swing.             window.robot.finder().
                                                    This class is used to generate native system in-        findByLabel(label, type)
FEST is a Java-based framework for automated
                                                    put events for the applications, for which input
functional GUI testing, which provides a flu-
                                                    through the mouse and keyboard is needed. This finder will find a component by its refer-
ent interface. FEST is an acronym and stands
                                                    FEST has created an abstraction interface and enced label.
for “Fixtures for Easy Software Testing”. Test
                                                    the implementation delegates the calls to the
cases are implemented as unit tests, and ap-                                                             After selecting a component, it is possible to
                                                    robot class of the JDK.
plications based on Swing and SwingFX can                                                                interact with this component. As shown in the
be tested. This framework is further developed The “component driver” layer contains example, the input of keyboards can be simu-
actively and the javadoc coverage of the source driver classes for all Swing GUI components. lated, just as mouse click events can be sent to
code is high. It has an active community; ques- The driver knows in detail which types of in- the components.
tions on the mailing list are answered very fast teraction are possible and how the state can be
and efficiently. The existing wiki pages also checked. The JTextFieldDriver inter- The components used in the example are only
inform about advanced topics. Based on the face, for example, contains methods like:                     simple GUI components. However, how easy
fluent interface offered and the good javadoc                                                            is the selection of a special node of a JTree?
descriptions, intuitive learning is possible.       •	         enterText(..)                             Imagine a folder structure that is displayed in
                                                                                                         a tree:
FEST is divided into four modules:                  •	         setText(…)
                                                                                                         •	 My Documents
•	 Swing                                            •	         requireText(…)
                                                                                                               ◦◦ FEST
      Simulation of user-generated events and •	               requireEditable(…)
      solid GUI component lookup                                                                                    ▪▪ Article
                                                    The component “fixture layer” is located
•	 Assertion3                                       on top of the driver layer and provides a DSL-                  ▪▪ Sample
                                                    oriented API for the tester. The main differ-
      Flexible and fluent assertions                ence between the driver and fixture layers is              ◦◦ FitNesse
                                                    the different style of programming. The driver The leaf node “Sample” can be selected using
•	 Reflection4
                                                    layer is designed in a classic object-oriented the JTreeFixture:
      ‘Fluent interface’ for simplifying usage way and is used by the fixture layer. The fix-
      of reflection.                                ture layer is designed in a completely different       JTreeFixture myDocument-
                                                    way: every method returns the GUI compo-               sTree = JTreeFixture(Robot,
•	 Mock     5
                                                    nent fixture class itself to provide the ability of    “folderTree”);
      Eliminates code duplication and clearly method chaining. This fluent interface makes                 myDocumentsTree.
      separates mock expectations from code the API much easier to write and read.                         selectPath(“My Documents/
      to test, improving code readability                                                                  FEST/Sample”);
                                                    This small example enters a text into two text
The most important module for automated fields, selects a radio button and clicks on the
functional testing is the Swing module. The calculation button. The last step is the valida- Another more complex GUI component is a
                                                                                                                           JTable, which differentiates
                                                                                                                           between the rendering and
                                                  FEST Framework                                                           the editing of cells, e.g. a cell
                                                                                                                           displays only a text, but when
              Swing                     Assertion                    Reflection                       Mock                 you double-click on the cell, a
     Component Fixture                                                                                                     drop-down list is displayed.
                                                                                                                             The following Java code
      Component Driver                                                                                                       shows an interaction with the
                                                                                                                             To-Do-List table of the demo
          Basic Robot                                                                                                        application:
                                                                                                                             These short examples dem-
                                                                                                                             onstrate the elegance and
Figure 1: Overview of the modules of the FEST framework                                                                      the possibilities of the FEST
                                                          tion of the calculation. Isn’t this code easy to   framework testing Swing applications – the
2	         http://www.infoq.com/articles/internal-
                                                          read and understand?                               new rich internet application technology
dsls-java
3	         http://docs.codehaus.org/display/FEST/         By default, all GUI components can be identi-      SwingFX is also testable. For readers who are
FEST-Assert                                               fied by name, as in the example, or by type.       interested in more examples, a good starting
4	         http://docs.codehaus.org/display/FEST/                                                            point is the sample application of this article
                                                          However, there are also more sophisticated
FEST-Reflect                                                                                                 with more FEST samples7.
5	         http://docs.codehaus.org/display/FEST/         6	        http://java.sun.com/javase/6/docs/
FEST-Mocks                                                api/java/awt/Robot.html                            7	        http://github.com/DominikDary/ToDo-


www.testingexperience.com                                                                         The Magazine for Professional Testers                  83
Figure 2: Screenshot of the sample application




                                                   //import static org.fest.swing.data.TableCell.row;
                                                                                                                                         Biography
                                                                                                                                         Dominik Dary is a Software Engineer
                                                   //Find table GUI component
                                                                                                                                         working for Capgemini sd&m AG in
                                                   JTableFixture taskTable = window.                                                     Germany. Dominik has 5 years practical
                                                   table(“toDoListTable”);                                                               experience in specification and realiza-
                                                   		                                                                                    tion of object-oriented software in Java
                                                   //Selecting the finish cell                                                           / Spring / JEE as well as in quality as-
                                                   JTableCellFixture finishedCell = taskTable.                                           surance and in business intelligence. In
                                                   cell(row(0).column(2));                                                               2005 he wrote his diploma thesis about
                                                   		                                                                                    “Quality Assurance in JEE Projects by
                                                   // Selecting the checkbox                                                             Test-Driven Development”. The practi-
                                                   finishedCell.enterValue(“true”);                                                      cal part of this thesis is based on the
                                                   finishedCell.background().requireEqualTo(Color.                                       “Cactus” and the “Canoo webtest”
                                                   GREEN);                                                                               frameworks.
                                                   		
                                                   //Selecting the project cell                                                          Dominik’s first contact with FEST was in
                                                   JTableCellFixture projectCell = taskTable.                                            2008 developing a Java Swing document
                                                   cell(row(0).column(3));                                                               management / workflow application. His
                                                   		                                                                                    further activities in this project included
                                                   // Select a value in the comboBox                                                     test specification and organization of
                                                   projectCell.enterValue(“Spring DM”);                                                  acceptance tests.
                                                   		
                                                   // Assert the selected value is displayed afterwards                                  In his current project, Dominik works
                                                   projectCell.requireValue(“Spring DM”);                                                for an e-commerce company doing test
                                                                                                                                         management, performance testing and
                                                                                                                                         automated testing with the selenium
                                                 FEST tests are written as unit tests; both popular frameworks - JUnit and TestNG
                                                                                                                                         framework.
                                                 – are supported. If TestNG is used as unit test framework, this offers the possibil-
                                                 ity to create your own reports. During testing the application, screenshots can be
                                                 taken using the ScreenshotTaker manually or automatically if the test fails. Those
                                                 functional tests can be integrated8 into continuous integration environments like
                                                 Hudson9 or TeamCity10.
                                                 For self-developed GUI components, it is helpful to create driver and fixture classes
                                                 as they exist for the Swing components. Another helpful approach is to create fix-
                                                 ture classes for GUI dialogs to offer methods for easy component selection and
                                                 some simple flows, e.g. choosing a file with JFileChooser which can be centralized.
                                                 This helps to minimize code duplication, simplifies the tests and increases once
                                                 more the readability of the tests. Newly designed and developed Swing desktop
                                                 applications are much easier to test if code conventions contain a naming concept
                                                 to guarantee that each GUI component has a unique name.
                                                 Tests of complex desktop applications need a flexible, well-documented framework
                                                 to create maintainable tests; check out the sample application and get started writ-
                                                 ing functional tests with FEST!


                                                 List
                                                 8	        http://docs.codehaus.org/display/FEST/Continuous+Integration
                                                 9	        https://hudson.dev.java.net/
                                                 10	       http://www.jetbrains.com/teamcity/


                                                 84                The Magazine for Professional Testers                                                www.testingexperience.com

Weitere ähnliche Inhalte

Was ist angesagt?

An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitweili_at_slideshare
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterVijayChowthri Nagaprakasham
 
Unit testing with NUnit
Unit testing with NUnitUnit testing with NUnit
Unit testing with NUnitkleinron
 
Alexandre Iline Rit 2010 Java Fxui
Alexandre Iline Rit 2010 Java FxuiAlexandre Iline Rit 2010 Java Fxui
Alexandre Iline Rit 2010 Java Fxuirit2010
 
How to debugging
How to debuggingHow to debugging
How to debuggingSiya Lee
 
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case Study
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case StudyModel-based Testing using Microsoft’s Spec Explorer Tool: A Case Study
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case StudyDharmalingam Ganesan
 
Unit testing on embedded target with C++Test
Unit testing on embedded  target with C++TestUnit testing on embedded  target with C++Test
Unit testing on embedded target with C++TestEngineering Software Lab
 
Open Source Software Testing Tools
Open Source Software Testing ToolsOpen Source Software Testing Tools
Open Source Software Testing ToolsVaruna Harshana
 
Alexandre.iline rit 2010 java_fxui_extra
Alexandre.iline rit 2010 java_fxui_extraAlexandre.iline rit 2010 java_fxui_extra
Alexandre.iline rit 2010 java_fxui_extrarit2010
 
Automated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsAutomated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsDharmalingam Ganesan
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Automatic Test Case Generation
Automatic Test Case GenerationAutomatic Test Case Generation
Automatic Test Case GenerationAdnan Causevic
 
プレゼンビフォアアフタ
プレゼンビフォアアフタプレゼンビフォアアフタ
プレゼンビフォアアフタTsuyoshi Ushio
 
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.» Lviv QA Day 2019
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.»  Lviv QA Day 2019МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.»  Lviv QA Day 2019
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.» Lviv QA Day 2019GoQA
 

Was ist angesagt? (20)

An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnit
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional Tester
 
Unit testing with NUnit
Unit testing with NUnitUnit testing with NUnit
Unit testing with NUnit
 
Alexandre Iline Rit 2010 Java Fxui
Alexandre Iline Rit 2010 Java FxuiAlexandre Iline Rit 2010 Java Fxui
Alexandre Iline Rit 2010 Java Fxui
 
Automation testing core
Automation testing coreAutomation testing core
Automation testing core
 
How to debugging
How to debuggingHow to debugging
How to debugging
 
Nunit
NunitNunit
Nunit
 
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case Study
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case StudyModel-based Testing using Microsoft’s Spec Explorer Tool: A Case Study
Model-based Testing using Microsoft’s Spec Explorer Tool: A Case Study
 
Nunit
NunitNunit
Nunit
 
Unit testing on embedded target with C++Test
Unit testing on embedded  target with C++TestUnit testing on embedded  target with C++Test
Unit testing on embedded target with C++Test
 
Open Source Software Testing Tools
Open Source Software Testing ToolsOpen Source Software Testing Tools
Open Source Software Testing Tools
 
Toolmaking for Administrators using Windows PowerShell
Toolmaking for Administrators using Windows PowerShellToolmaking for Administrators using Windows PowerShell
Toolmaking for Administrators using Windows PowerShell
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
Alexandre.iline rit 2010 java_fxui_extra
Alexandre.iline rit 2010 java_fxui_extraAlexandre.iline rit 2010 java_fxui_extra
Alexandre.iline rit 2010 java_fxui_extra
 
Test Automation
Test Automation Test Automation
Test Automation
 
Automated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from ModelsAutomated Test Case Generation and Execution from Models
Automated Test Case Generation and Execution from Models
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Automatic Test Case Generation
Automatic Test Case GenerationAutomatic Test Case Generation
Automatic Test Case Generation
 
プレゼンビフォアアフタ
プレゼンビフォアアフタプレゼンビフォアアフタ
プレゼンビフォアアフタ
 
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.» Lviv QA Day 2019
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.»  Lviv QA Day 2019МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.»  Lviv QA Day 2019
МАКСИМ БАРВІНСЬКИЙ «AspectJ in Test Automation.» Lviv QA Day 2019
 

Ähnlich wie Functional tests with the FEST framework

Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test CompleteVartika Saxena
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio
 
Choosing right-automation-tool
Choosing right-automation-toolChoosing right-automation-tool
Choosing right-automation-toolBabuDevanandam
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in PracticeSteven Mak
 
DevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationDevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationIRJET Journal
 
An Approach To Erp Testing Using Services
An Approach To Erp Testing Using ServicesAn Approach To Erp Testing Using Services
An Approach To Erp Testing Using ServicesSagi Schliesser
 
5 sins of all hands ppt
5 sins of all hands ppt5 sins of all hands ppt
5 sins of all hands pptSpike Gu
 
Overview and Analysis of Automated Testing Tools: Ranorex, Test Complete, Se...
Overview and Analysis of Automated Testing Tools:  Ranorex, Test Complete, Se...Overview and Analysis of Automated Testing Tools:  Ranorex, Test Complete, Se...
Overview and Analysis of Automated Testing Tools: Ranorex, Test Complete, Se...IRJET Journal
 
XML2Selenium Technical Presentation
XML2Selenium Technical PresentationXML2Selenium Technical Presentation
XML2Selenium Technical Presentationjazzteam
 
CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWDVikas Sarin
 
Selenium Automation Framework (SAF).
Selenium Automation Framework (SAF).Selenium Automation Framework (SAF).
Selenium Automation Framework (SAF).Mindtree Ltd.
 
Planning & building scalable test infrastructure
Planning  & building scalable test infrastructurePlanning  & building scalable test infrastructure
Planning & building scalable test infrastructureVijayan Reddy
 
Basics of Scriptless Automation for Web and Mobile Apps (1).pdf
Basics of Scriptless Automation for Web and Mobile Apps (1).pdfBasics of Scriptless Automation for Web and Mobile Apps (1).pdf
Basics of Scriptless Automation for Web and Mobile Apps (1).pdfpcloudy2
 
HTAF 2.0 - A hybrid test automation framework.
HTAF 2.0 - A hybrid test automation framework.HTAF 2.0 - A hybrid test automation framework.
HTAF 2.0 - A hybrid test automation framework.Mindtree Ltd.
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
Automated testing of JavaFX GUI components
Automated testing of JavaFX GUI componentsAutomated testing of JavaFX GUI components
Automated testing of JavaFX GUI componentsWolfgang Weigend
 

Ähnlich wie Functional tests with the FEST framework (20)

Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test Complete
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and Developers
 
Choosing right-automation-tool
Choosing right-automation-toolChoosing right-automation-tool
Choosing right-automation-tool
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in Practice
 
DevOps CI Automation Continuous Integration
DevOps CI Automation Continuous IntegrationDevOps CI Automation Continuous Integration
DevOps CI Automation Continuous Integration
 
An Approach To Erp Testing Using Services
An Approach To Erp Testing Using ServicesAn Approach To Erp Testing Using Services
An Approach To Erp Testing Using Services
 
5 sins of all hands ppt
5 sins of all hands ppt5 sins of all hands ppt
5 sins of all hands ppt
 
Overview and Analysis of Automated Testing Tools: Ranorex, Test Complete, Se...
Overview and Analysis of Automated Testing Tools:  Ranorex, Test Complete, Se...Overview and Analysis of Automated Testing Tools:  Ranorex, Test Complete, Se...
Overview and Analysis of Automated Testing Tools: Ranorex, Test Complete, Se...
 
XML2Selenium Technical Presentation
XML2Selenium Technical PresentationXML2Selenium Technical Presentation
XML2Selenium Technical Presentation
 
CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWD
 
Rajiv Profile
Rajiv ProfileRajiv Profile
Rajiv Profile
 
Selenium Automation Framework (SAF).
Selenium Automation Framework (SAF).Selenium Automation Framework (SAF).
Selenium Automation Framework (SAF).
 
Planning & building scalable test infrastructure
Planning  & building scalable test infrastructurePlanning  & building scalable test infrastructure
Planning & building scalable test infrastructure
 
Basics of Scriptless Automation for Web and Mobile Apps (1).pdf
Basics of Scriptless Automation for Web and Mobile Apps (1).pdfBasics of Scriptless Automation for Web and Mobile Apps (1).pdf
Basics of Scriptless Automation for Web and Mobile Apps (1).pdf
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
HTAF 2.0 - A hybrid test automation framework.
HTAF 2.0 - A hybrid test automation framework.HTAF 2.0 - A hybrid test automation framework.
HTAF 2.0 - A hybrid test automation framework.
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
Automated testing of JavaFX GUI components
Automated testing of JavaFX GUI componentsAutomated testing of JavaFX GUI components
Automated testing of JavaFX GUI components
 

Mehr von Dominik Dary

Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in ActionDominik Dary
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for AndroidDominik Dary
 
Android Test Automation – one year later
Android Test Automation – one year laterAndroid Test Automation – one year later
Android Test Automation – one year laterDominik Dary
 
Mobile WebDriver Selendroid
Mobile WebDriver SelendroidMobile WebDriver Selendroid
Mobile WebDriver SelendroidDominik Dary
 
Applied Testing Heuristics in the Context of eBay
Applied Testing Heuristics in the Context of eBayApplied Testing Heuristics in the Context of eBay
Applied Testing Heuristics in the Context of eBayDominik Dary
 
Calabash Driver Lightning Talk from the mobile test summit.
Calabash Driver Lightning Talk from the mobile test summit.Calabash Driver Lightning Talk from the mobile test summit.
Calabash Driver Lightning Talk from the mobile test summit.Dominik Dary
 
Mobile Test Automation at eBay
Mobile Test Automation at eBayMobile Test Automation at eBay
Mobile Test Automation at eBayDominik Dary
 
Agile Testing at eBay
Agile Testing at eBayAgile Testing at eBay
Agile Testing at eBayDominik Dary
 
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source Tools
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source ToolsInfoCamp 12 Keynote - Innovation in the fast lane with Open Source Tools
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source ToolsDominik Dary
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsDominik Dary
 
Software Measurement in agilen Projekten mit Open Source Tools
Software Measurement in agilen Projekten mit Open Source ToolsSoftware Measurement in agilen Projekten mit Open Source Tools
Software Measurement in agilen Projekten mit Open Source ToolsDominik Dary
 

Mehr von Dominik Dary (11)

Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in Action
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for Android
 
Android Test Automation – one year later
Android Test Automation – one year laterAndroid Test Automation – one year later
Android Test Automation – one year later
 
Mobile WebDriver Selendroid
Mobile WebDriver SelendroidMobile WebDriver Selendroid
Mobile WebDriver Selendroid
 
Applied Testing Heuristics in the Context of eBay
Applied Testing Heuristics in the Context of eBayApplied Testing Heuristics in the Context of eBay
Applied Testing Heuristics in the Context of eBay
 
Calabash Driver Lightning Talk from the mobile test summit.
Calabash Driver Lightning Talk from the mobile test summit.Calabash Driver Lightning Talk from the mobile test summit.
Calabash Driver Lightning Talk from the mobile test summit.
 
Mobile Test Automation at eBay
Mobile Test Automation at eBayMobile Test Automation at eBay
Mobile Test Automation at eBay
 
Agile Testing at eBay
Agile Testing at eBayAgile Testing at eBay
Agile Testing at eBay
 
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source Tools
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source ToolsInfoCamp 12 Keynote - Innovation in the fast lane with Open Source Tools
InfoCamp 12 Keynote - Innovation in the fast lane with Open Source Tools
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
 
Software Measurement in agilen Projekten mit Open Source Tools
Software Measurement in agilen Projekten mit Open Source ToolsSoftware Measurement in agilen Projekten mit Open Source Tools
Software Measurement in agilen Projekten mit Open Source Tools
 

Functional tests with the FEST framework

  • 1. ISSN 1866-5705 www.testingexperience.com free digital version print version 8,00 € printed in Germany 8 Standards – What about it? The Magazine for Professional Testers December, 2009 © iStockphoto.com/belknap
  • 2. © iStockphoto.com/aabejon Functional tests with the FEST framework by Dominik Dary This article describes an easy and quick (e.g. FitNesse) is used for user acceptance tant for whom the application is designed. way to write robust and compact tests for tests in which the tests are written using If the application is developed for experts Swing-rich applications using the open simple tables in html files. Each line with a lot of specialized views and with source framework FEST. represents an interaction with the GUI a number of extended and self-developed through a command like “enter text”. The GUI components, a technical framework In most projects a lot of time is used for testing columns are used for commands, con- is much more flexible. the application with unit tests and functional text, selector, arguments and comments. Graphical User Interface (GUI) tests, which • From a technical perspective, the usage GUI components are identified inside the makes the entire system safer and more robust. of a technical framework with a well- GUI-Dialog by their unique name. This Most of these functional tests are often done defined API offers the possibility to use simple approach can be used by testers manually, which is very time consuming. code editors, in which the syntax is high- without IT background and adds a layer lighted and typing errors are displayed. Automated GUI tests can be used for verify- of abstraction onto writing automated These editors offer code completion, ing the main scenarios of the application. GUI tests. refactoring, debugging and integration of testing is also essential during application • Technical Frameworks: These tests are various version control systems, so that maintenance; with automated tests, the impact written in traditional programming lan- the history of the test file can be compared of refactorings can be tested within minutes. guages like Java or Ruby. Components to each version. Another advantage is the The aspect of visualizing the GUI components are also identified by the name of the power of the programming language (e.g. is not the main intent of this test approach. component or more complex component all features of the Java language can be Test frameworks should provide a solid way lookups. The biggest disadvantage of this used) and the fact that existing utility of finding GUI components, to get robust tests approach is the required basic know-how classes can be reused. The biggest disad- that are also able to run after layout changes. about software development and the time vantage is the necessary Java know-how An intuitive and well-documented test frame- needed to learn the – in some cases cryp- of the testers. work is important for the readability of the tic – technical framework Application But what does a well-defined API mean? Eric written tests and allows the tester a more rapid Programming Interface (API). Evans and Martin Fowler invented the term of learning. A very important criteria for selecting a test “fluent interface”, which is a design principle Those functional tests describe scenarios. In- framework is its maintainability and the dura- for an object-oriented API with the objective side a task manager application, a test scenario tion of the training period. Capture and replay to offer a more readable code that is only used can be e.g. the entering of new to do items. tools are at first glance an easy and fast way to within a limited scope (e.g. functional GUI This process includes several steps, such as create test scripts. But these scripts are error- testing)1. A special characteristic of this design opening the new task form, entering some val- prone, especially if the layout of the applica- is the return value of a method call, which en- ues into the text fields and clicking the “cre- tion has changed. ables to build a method chain of a class. ate” button. Afterwards the created task must Keyword-driven testing enables domain ex- A sample code can look like this: be verified. This can be done using the GUI, perts to use this approach, because of the e.g. by loading the task form, or directly in the dialog.botton(“login”).click(); simplicity of the test case specification. These database to assert the entered values are saved tests can be created with editors like Word, and correctly. In this code sample, the login button is resolved there’s a basic concept of modularization. Be- by its name and afterwards a click event is dis- The tools employed in GUI test automation low these frameworks, technical frameworks patched to it. This type of API is a so-called can be categorized as follows: like JFCUnit are used. fluent interface, which offers the developers • Capture and Replay: Testers click on If keyword-driven testing simplifies the usage the possibility to enhance an API to a domain- the test scenarios and thereafter the test of technical frameworks, why should a team specific language (DSL). A DSL is commonly framework captures all GUI interactions, decide to use a technical framework? described as a computer language targeted at a which are stored in a script that can be particular kind of problem and not intended to This question can be answered from a domain replayed automatically. view and a technical view: • Keyword-driven testing: This approach 1 http://www.martinfowler.com/bliki/Flu- • From a domain perspective, it is impor- entInterface.html 82 The Magazine for Professional Testers www.testingexperience.com
  • 3. solve problems outside of its domain.2 other modules can be Sample test code using the FEST API optionally used and //Fill in parameters FEST Framework are not described in window.textBox(“firstNumberInput”).enterText(“22”); Open Source Library for GUI Testing this article. window.textBox(“secondNumberInput”).enterText(“2”); • Supports functional Swing GUI test- (See Figure 1) ing //Select action • Website: http://fest.easytesting.org The Swing module is window.radioButton(“sumRadioButton”).check(); • Its API provides a fluent interface divided into different //Calculate • Open Source project (Apache 2.0 layers. “Basic ro- window.button(“calculateButton”).click(); license) bot” is the basic layer of the FEST-Swing //Validate the result • Supports both TestNG and JUnit window.textBox(“resultOutput”).requireText(“24”); module. The class • Simplifies troubleshooting GUI test java.awt.Robot , 6 failures finders that can be used. which is part of the Java Development Kit • Hosted at CodeHaus (JDK), is the main component of FEST-Swing. window.robot.finder(). This class is used to generate native system in- findByLabel(label, type) FEST is a Java-based framework for automated put events for the applications, for which input functional GUI testing, which provides a flu- through the mouse and keyboard is needed. This finder will find a component by its refer- ent interface. FEST is an acronym and stands FEST has created an abstraction interface and enced label. for “Fixtures for Easy Software Testing”. Test the implementation delegates the calls to the cases are implemented as unit tests, and ap- After selecting a component, it is possible to robot class of the JDK. plications based on Swing and SwingFX can interact with this component. As shown in the be tested. This framework is further developed The “component driver” layer contains example, the input of keyboards can be simu- actively and the javadoc coverage of the source driver classes for all Swing GUI components. lated, just as mouse click events can be sent to code is high. It has an active community; ques- The driver knows in detail which types of in- the components. tions on the mailing list are answered very fast teraction are possible and how the state can be and efficiently. The existing wiki pages also checked. The JTextFieldDriver inter- The components used in the example are only inform about advanced topics. Based on the face, for example, contains methods like: simple GUI components. However, how easy fluent interface offered and the good javadoc is the selection of a special node of a JTree? descriptions, intuitive learning is possible. • enterText(..) Imagine a folder structure that is displayed in a tree: FEST is divided into four modules: • setText(…) • My Documents • Swing • requireText(…) ◦◦ FEST Simulation of user-generated events and • requireEditable(…) solid GUI component lookup ▪▪ Article The component “fixture layer” is located • Assertion3 on top of the driver layer and provides a DSL- ▪▪ Sample oriented API for the tester. The main differ- Flexible and fluent assertions ence between the driver and fixture layers is ◦◦ FitNesse the different style of programming. The driver The leaf node “Sample” can be selected using • Reflection4 layer is designed in a classic object-oriented the JTreeFixture: ‘Fluent interface’ for simplifying usage way and is used by the fixture layer. The fix- of reflection. ture layer is designed in a completely different JTreeFixture myDocument- way: every method returns the GUI compo- sTree = JTreeFixture(Robot, • Mock 5 nent fixture class itself to provide the ability of “folderTree”); Eliminates code duplication and clearly method chaining. This fluent interface makes myDocumentsTree. separates mock expectations from code the API much easier to write and read. selectPath(“My Documents/ to test, improving code readability FEST/Sample”); This small example enters a text into two text The most important module for automated fields, selects a radio button and clicks on the functional testing is the Swing module. The calculation button. The last step is the valida- Another more complex GUI component is a JTable, which differentiates between the rendering and FEST Framework the editing of cells, e.g. a cell displays only a text, but when Swing Assertion Reflection Mock you double-click on the cell, a Component Fixture drop-down list is displayed. The following Java code Component Driver shows an interaction with the To-Do-List table of the demo Basic Robot application: These short examples dem- onstrate the elegance and Figure 1: Overview of the modules of the FEST framework the possibilities of the FEST tion of the calculation. Isn’t this code easy to framework testing Swing applications – the 2 http://www.infoq.com/articles/internal- read and understand? new rich internet application technology dsls-java 3 http://docs.codehaus.org/display/FEST/ By default, all GUI components can be identi- SwingFX is also testable. For readers who are FEST-Assert fied by name, as in the example, or by type. interested in more examples, a good starting 4 http://docs.codehaus.org/display/FEST/ point is the sample application of this article However, there are also more sophisticated FEST-Reflect with more FEST samples7. 5 http://docs.codehaus.org/display/FEST/ 6 http://java.sun.com/javase/6/docs/ FEST-Mocks api/java/awt/Robot.html 7 http://github.com/DominikDary/ToDo- www.testingexperience.com The Magazine for Professional Testers 83
  • 4. Figure 2: Screenshot of the sample application //import static org.fest.swing.data.TableCell.row; Biography Dominik Dary is a Software Engineer //Find table GUI component working for Capgemini sd&m AG in JTableFixture taskTable = window. Germany. Dominik has 5 years practical table(“toDoListTable”); experience in specification and realiza- tion of object-oriented software in Java //Selecting the finish cell / Spring / JEE as well as in quality as- JTableCellFixture finishedCell = taskTable. surance and in business intelligence. In cell(row(0).column(2)); 2005 he wrote his diploma thesis about “Quality Assurance in JEE Projects by // Selecting the checkbox Test-Driven Development”. The practi- finishedCell.enterValue(“true”); cal part of this thesis is based on the finishedCell.background().requireEqualTo(Color. “Cactus” and the “Canoo webtest” GREEN); frameworks. //Selecting the project cell Dominik’s first contact with FEST was in JTableCellFixture projectCell = taskTable. 2008 developing a Java Swing document cell(row(0).column(3)); management / workflow application. His further activities in this project included // Select a value in the comboBox test specification and organization of projectCell.enterValue(“Spring DM”); acceptance tests. // Assert the selected value is displayed afterwards In his current project, Dominik works projectCell.requireValue(“Spring DM”); for an e-commerce company doing test management, performance testing and automated testing with the selenium FEST tests are written as unit tests; both popular frameworks - JUnit and TestNG framework. – are supported. If TestNG is used as unit test framework, this offers the possibil- ity to create your own reports. During testing the application, screenshots can be taken using the ScreenshotTaker manually or automatically if the test fails. Those functional tests can be integrated8 into continuous integration environments like Hudson9 or TeamCity10. For self-developed GUI components, it is helpful to create driver and fixture classes as they exist for the Swing components. Another helpful approach is to create fix- ture classes for GUI dialogs to offer methods for easy component selection and some simple flows, e.g. choosing a file with JFileChooser which can be centralized. This helps to minimize code duplication, simplifies the tests and increases once more the readability of the tests. Newly designed and developed Swing desktop applications are much easier to test if code conventions contain a naming concept to guarantee that each GUI component has a unique name. Tests of complex desktop applications need a flexible, well-documented framework to create maintainable tests; check out the sample application and get started writ- ing functional tests with FEST! List 8 http://docs.codehaus.org/display/FEST/Continuous+Integration 9 https://hudson.dev.java.net/ 10 http://www.jetbrains.com/teamcity/ 84 The Magazine for Professional Testers www.testingexperience.com