Date post: | 15-Jan-2017 |
Category: |
Software |
Upload: | aurelien-pupier |
View: | 686 times |
Download: | 2 times |
Functional Testing made easy with SWTBot for Developers and Testers Aurelien Pupier - @apupier
Studio Development Leader
© 2015 Bonitasoft 2
What is SWTBot?
Java Framework for SWT automated UI tests
© 2015 Bonitasoft 3
And also…
SWTBot – General workings
• Encapsulate UI components
• Send SWT Events to simulate User interaction
4 © 2015 Bonitasoft
SWTBot – Sample
5 © 2015 Bonitasoft
bot.textWithLabel(“Name *”).setText(“userName”);
bot.comboBox().select(“Text”);
bot.textWithLabel(“Default value”).setText(“john”);
bot.button(“Finish”).click();
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
SWTBot limitations (1/5)
• Underlying components knowledge
– Widget types
– Eclipse wording
7 © 2015 Bonitasoft
Table or List?
Combo or CCombo?
SWTBot limitations (2/5)
• Same widget at different place
– SWTBotConstants.SWTBOT_WIDGET_ID_KEY
– production code modified
8 © 2015 Bonitasoft
SWTBot limitations (3/5)
• UI Thread synchronization Robustness hard:
– Correct implementation of waitUntil required
– (even if Conditions provided)
9 © 2015 Bonitasoft
SWTBot limitations (4/5)
• Java code not accessible for Java/Eclipse beginners
– For all previously mentioned reasons
10 © 2015 Bonitasoft
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
SWTBot conclusion
SWTBot is an handy test tool
for developers
12 © 2015 Bonitasoft
What about testers?
• How to let testers writing Functional tests?
– Do not care of implementation details
13 © 2015 Bonitasoft
Application Oriented API
‘Page Object Pattern’
14 © 2015 Bonitasoft
Application Oriented API
15 © 2015 Bonitasoft
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 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));
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
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
Feedback on implementation
• Setup time ~3 weeks
• On the fly
20 © 2015 Bonitasoft
What’s next?
21 © 2015 Bonitasoft
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
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
24 © 2015 Bonitasoft