Functional Testing made easy with SWTBot for Developers and Testers

23
Functional Testing made easy with SWTBot for Developers and Testers Aurelien Pupier - @apupier Studio Development Leader © 2015 Bonitasoft 2

Transcript of Functional Testing made easy with SWTBot for Developers and Testers

Page 1: Functional Testing made easy with SWTBot for Developers and Testers

Functional Testing made easy with SWTBot for Developers and Testers Aurelien Pupier - @apupier

Studio Development Leader

© 2015 Bonitasoft 2

Page 2: Functional Testing made easy with SWTBot for Developers and Testers

What is SWTBot?

Java Framework for SWT automated UI tests

© 2015 Bonitasoft 3

And also…

Page 3: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot – General workings

• Encapsulate UI components

• Send SWT Events to simulate User interaction

4 © 2015 Bonitasoft

Page 4: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot – Sample

5 © 2015 Bonitasoft

bot.textWithLabel(“Name *”).setText(“userName”);

bot.comboBox().select(“Text”);

bot.textWithLabel(“Default value”).setText(“john”);

bot.button(“Finish”).click();

Page 5: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot – Advantages

• Easy to understand for developers

• Easy to write first shot

• … Even a recorder

• Access to Java API for assertions

• Test code coverage

6 © 2015 Bonitasoft

Page 6: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot limitations (1/5)

• Underlying components knowledge

– Widget types

– Eclipse wording

7 © 2015 Bonitasoft

Table or List?

Combo or CCombo?

Page 7: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot limitations (2/5)

• Same widget at different place

– SWTBotConstants.SWTBOT_WIDGET_ID_KEY

– production code modified

8 © 2015 Bonitasoft

Page 8: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot limitations (3/5)

• UI Thread synchronization Robustness hard:

– Correct implementation of waitUntil required

– (even if Conditions provided)

9 © 2015 Bonitasoft

Page 9: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot limitations (4/5)

• Java code not accessible for Java/Eclipse beginners

– For all previously mentioned reasons

10 © 2015 Bonitasoft

Page 10: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot limitations (5/5)

• Maintenance of tests:

– Requires to be close to production code

• Message updated (to fix a typo)

• UI updated (from Combo to CCombo…)

11 © 2015 Bonitasoft

Page 11: Functional Testing made easy with SWTBot for Developers and Testers

SWTBot conclusion

SWTBot is an handy test tool

for developers

12 © 2015 Bonitasoft

Page 12: Functional Testing made easy with SWTBot for Developers and Testers

What about testers?

• How to let testers writing Functional tests?

– Do not care of implementation details

13 © 2015 Bonitasoft

Page 13: Functional Testing made easy with SWTBot for Developers and Testers

Application Oriented API

‘Page Object Pattern’

14 © 2015 Bonitasoft

Page 14: Functional Testing made easy with SWTBot for Developers and Testers

Application Oriented API

15 © 2015 Bonitasoft

Page 15: Functional Testing made easy with SWTBot for Developers and Testers

Page Pattern sample (1/2)

16 © 2015 Bonitasoft

new BotDataDialog().

.setName(“userName”)

.setType(“Text”)

.setDefaultValue(“john”)

.finish();

bot.waitUntil(Conditions.shellIsActive(Messages.newVariable));

SWTBotShell shell = bot.activeShell();

bot.textWithLabel(Messages.name_mandatory).setText(“userName”);

bot.comboBox().select(“Text”);

bot.textWithLabel(Messages.defaultValue).setText(“john”);

bot.button(IDialogConstants.FINISH_LABEL).click();

bot.waitUntil(Conditions.shellCloses(shell));

Page 16: Functional Testing made easy with SWTBot for Developers and Testers

Page Pattern sample (2/2)

17 © 2015 Bonitasoft

new BotDataDialog().

.setName(“userName”)

.setType(“Text”)

.setDefaultValue(“john”)

.finish();

bot.waitUntil(Conditions.shellIsActive(Messages.newVariable));

SWTBotShell shell = bot.activeShell();

bot.textWithLabel(Messages.name_mandatory).setText(“userName”);

bot.comboBox().select(“Text”);

bot.textWithLabel(Messages.defaultValue).setText(“john”);

bot.button(IDialogConstants.FINISH_LABEL).click();

bot.waitUntil(Conditions.shellCloses(shell));

Page 17: Functional Testing made easy with SWTBot for Developers and Testers

What decided us?

• Successful implementation with Selenium and

Chinese QA team

• Code mess

– Big static utility classes…

– Sometimes right utility class hard to find

• Robustness issue

– CI infra updated ~10% of UI tests unstable

• Half-day for one test

• Invite QA testers to join the party

• Same tooling Development/QA

18 © 2015 Bonitasoft

Page 18: Functional Testing made easy with SWTBot for Developers and Testers

Observed benefits

Eases writing…

… and maintaining Functional Tests

… for Testers AND Developers

– New UI test: Half-day 1 hour

– More factorized code

– Robustness

19 © 2015 Bonitasoft

Page 19: Functional Testing made easy with SWTBot for Developers and Testers

Feedback on implementation

• Setup time ~3 weeks

• On the fly

20 © 2015 Bonitasoft

Page 20: Functional Testing made easy with SWTBot for Developers and Testers

What’s next?

21 © 2015 Bonitasoft

Page 21: Functional Testing made easy with SWTBot for Developers and Testers

What’s next?

• BDD

– Get stake holders and user advocates to join the party

– Talk about using Cucumber with SWTBot

• RedDeer

– Reuse the Eclipse components

22 © 2015 Bonitasoft

Page 22: Functional Testing made easy with SWTBot for Developers and Testers

Visit us online bonitasoft.com

Join our community Bonitasoft.org

Download Bonitasoft.com/downloads

Follow us on twitter @bonitasoft

“Page” your App!

@apupier

© 2015 Bonitasoft 23

Page 23: Functional Testing made easy with SWTBot for Developers and Testers

24 © 2015 Bonitasoft