Java

  • Uploaded by: Banhi
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java as PDF for free.

More details

  • Words: 707
  • Pages: 25
UI Automated Testing of Java Applications

Jiří Skřivánek Sun Microsystems 360

2

Introduction > Sun Microsystems > NetBeans > NetBeans Quality Engineering

3

AGENDA > > > > > > >

UI functional testing Jemmy testing library Jellytools testing library XTest Support in NetBeans IDE Demo Q&A

4

Why write automated tests? > Make sure code works (specification) – show the intended use and behavior of the code > Things do not get wrong (integration) – not to break existing functionality > Mistakes do not reappear (regression) – verify bug fixes > Detect unused code (code coverage) – delete obsolete code or improve tests > Measure UI responsiveness (performance) – only way how to daily check performance

5

How write tests? > Unit vs. functional > Who should write tests? – application code developers – unit – quality assurance engineers – functional > How many tests are enough? – manual – ad hoc testing – automated – save engineers cycles from repetitive testing > How often run tests? – before integration – daily

6

UI Functional Testing > Advantages – like real user input – reusability > Obstacles – stability of tests – changing UI > Existing tools – commercial (Functional Tester, SilkTest, WinRunner) – open-source (Abbot, Jemmy, JFCUnit, Marathon)

7

Jemmy Overview > > > > > >

Java library used to create UI automated tests Provides support covering all Swing components Can be easily extended for custom component support Two modes of action reproducing (Robot and event dispatching) Pre/post verification methods When test fails? – Jemmy exceptions and timeouts

8

Jemmy Operator Hierarchy Component

ComponentOperator

Container

ContainerOperator

JComponent

JComponentOperator

JLabel

JLabelOperator

9

Jemmy Operators > Find a window – JFrameOperator, JDialogOperator > Find a component inside container – by text – by ordinal index – by component name – using ComponentChooser > Interact with component – simulate user actions – call component API

10

Text Operator Diagram Text operations Mapping methods: getText(), getX(), getY, ...

Mouse operations

Text operator Keyboard operations

Events Dispatching mode Robot

11

Jemmy Code Example JFrameOperator frameOper = new JFrameOperator("Frame Title"); JTextFieldOperator textOper = new JTextFieldOperator(frameOper); textOper.typeText("A new text"); textOper.getText(); JButtonOperator buttonOper = new JButtonOperator(frameOper, "OK"); //JButtonOperator buttonOper = //

new JButtonOperator(frameOper, 1);

buttonOper.push();

12

Jellytools Overview > > > > >

UI test library for NetBeans Based on Jemmy Uses NetBeans API Operators for NetBeans UI components High-level functionality

13

Jemmy – Jellytools Diagram TEST

Jellytools

Jemmy

API

UI NetBeans

14

Jellytools Operators Extend Jemmy operator Provide access to all sub components Encapsulate localization Actions – menu, popup, shortcut, API > Nodes – handle tree-like structures > > > >

15

Jellytools Code Example NewFileWizardOperator wizardOper = NewFileWizardOperator.invoke(); wizardOper.selectProject("MyProject"); //JComboBoxOperator projectOper = // wizardOper.cboProject(); //projectOper.selectItem("MyProject"); wizardOper.next();

16

XTest Overview > > > >

Open-source test harness Runs tests based on JUnit Based on Ant XTest is able to – compile tests – run tests in plain JVM or in NetBeans IDE – publish test results as HTML pages

17

What Needed To Run Tests > > > > > > >

test case = JUnit test method test suite = JUnit suite test bag = a set of test suites test type (unit, qa-functional, ...) compiler/executor build scripts config files

18

Publishing Engine > HTML presentation of test results – grouped by suites, test bags, projects – detailed results of test case - status, time, exception stack trace, link to workdir > Publishing engine server – gather results from several sources – generate summary and history reports – publish using HTTP server

19

Support in NetBeans - Overview > > > >

JUnit module and NbJUnit extension Jemmy/Jellytools library modules JemmySupport module XTest module

20

JUnit Module and NbJUnit > JUnit support module – create unit test from existing classes – run unit tests > NbJUnit - extension to JUnit framework – assert files – working directory for each test case – memory usage

21

Jemmy/Jellytools Support > > > > >

Code completion Javadoc included JellyTestCase template Operator generator Jemmy UI browser

22

XTest Module > XTest harness distribution > XTest infrastructure wizard – build scripts – configuration files > Project actions

23

Demo

24

Motto

“People should think and machines should test.”

Jiří Skřivánek Sun Microsystems

http://testtools.netbeans.org [email protected]

Related Documents

Java Java
June 2020 44
Java
November 2019 24
Java
November 2019 26
Java
December 2019 27
Java
November 2019 23
Java
November 2019 25

More Documents from ""

Trigger
November 2019 39
Usecasedocument
November 2019 32
Javaui
April 2020 32
Java
April 2020 21
Stub Driver
November 2019 33