When it comes to getting XPages apps ready for production there's a lot to know. Do you have a web test automation suite in place to drive your apps through the browser and guarantee quality? Do you have a JUnit test framework to exercise your XPages components? Is your application accessible to the latest international standards? This session, direct from the XPages engineering team, shows how to automate your app dev processes using the very latest tools and standards so that your products are ahead of the game.
2. Please Note
IBM’s statements regarding its plans, directions, and intent are subject to change or withdrawal without notice at IBM’s sole
discretion.
Information regarding potential future products is intended to outline our general product direction and it should not be
relied on in making a purchasing decision.
The information mentioned regarding potential future products is not a commitment, promise, or legal obligation to deliver
any material, code or functionality. Information about potential future products may not be incorporated into any contract.
The development, release, and timing of any future features or functionality described for our products remains at our sole
discretion
Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment.
The actual throughput or performance that any user will experience will vary depending upon many factors, including
considerations such as the amount of multiprogramming in the user’s job stream, the I/O configuration, the storage
configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve
results similar to those stated here.
2
7. Session Goals
Examine technologies & best practices in the Testing & Tuning phases
Highlight best practices in Development stage
Profiling & Tuning
Testing
7
Application
Development
Lifecycle
Development
Deployment
7
9. Testing across multiple browsers, phones & tablets
■
Does your control/application render correctly on all browsers & platforms?
■
■
Does the functionality match what you expect on all browsers & platforms?
■
■
Do you have a mobile interface that works across devices?
Source: http://gs.statcounter.com
9
9
10. Selenium
Selenium is a browser automation framework
■
■
Selenium IDE – record & playback, auto-generates code
■
Source: http://seleniumhq.org
■
Selenium supports tests written in Python, Ruby, Perl, PHP and Java.
■
−
Latest version: Selenium v2.39
−
WebDriver API
●
ChromeDriver
●
IEDriver
●
FirefoxDriver
●
AndroidDriver
●
iPhoneDriver (+ iWebDriver app)
●
...and more
■
–
–
10
Source: http://gs.statcounter.com
10
11. TestNG
■
■
Testing framework based on JUnit
■
■
Run test suite & report the results
■
■
Provides results in HTML and XML format
–
Customisable format & layout
−
■
Take screenshots upon failures
■
■
TestNG Annotations, e.g:
–
–
–
@Test
@BeforeClass
@AfterMethod
−
■
Plugin for Eclipse/IBM Domino Designer ®
11
11
12. Combine Selenium & TestNG
1. Install TestNG plugin
2. Add Selenium jars to project build path
3. Create a Selenium test Java class
4. Create a WebDriver instance
5. Create a Selenium test method
6. Add TestNG annotation (@Test)
12
12
13. Combine Selenium & TestNG (ctd.)
7. Find WebElements using findElement()
& Selenium By class
8. Call methods on WebElements
XPath
By.xpath("//a[@id='view:_id1:link1']");
cssSelector
By.cssSelector("a[id='view:_id1:link1']");
linkText
By.linkText("click me");
others
By.id(...), By.className(...), By.tagName(...)
9. Perform assertions on expected outcomes
10. Create TestNG test suite XML file
11. Reference the Java class
12. Include @Test methods
13. Run the TestNG suite
13
13
15. Pitfalls and Best Practices
■
Don't use auto-generated ids
–
By.cssSelector("button[id='view:_id1:_id12:_id234_id56']");
■
■
■
WebDriver cannot interact with browser dialogs
–
Selenium workarounds available.
–
Other options - AutoIT and java.awt.Robot
■
■
Be careful with WebDriver & iframes
–
webDriver.switchTo().frame(String frameId);
■
Communication between Dev & Test
■
Developers can write automation!
■
■
15
Set ImplicitWait timeout value
–
webDriver.manage().timeouts().implicitlyWait(5,
TimeUnit.SECONDS);
User-Agent manipulation to emulate mobile device
testing
15
16. Selenium Grid
Allows for distributed parallel test execution
Central hub controls a number of nodes
Hub activates tests across available nodes
Source: http://seleniumhq.org
Nodes report results back to the hub
Parallel automated testing across browsers & platforms
Better & faster testing coverage
16
16
17. Jenkins
Java-based Open Source Continuous Integration Tool
Build software projects
Source: http://jenkins-ci.org
Test software projects
–
Automate the automation!
Monitor executions of externally-run jobs
Provides web interface for configuration and monitoring
Extensible – write your own Jenkins plugins
17
17
19. Building in Testability
Build a unit test suite to verify that a new or existing library of controls is fit for purpose
■
JUnit Overview
■
■
XPages JUnit Test Framework Overview
■
■
Creating an Example Test Suite
■
■
Demo
■
■
Pitfalls and Best Practices
19
19
20. JUnit Overview
■
JUnit is a unit testing framework for the Java programming language
■
■
Unit Tests ensure Java code is working as intended
–
Create an Object
–
Invoke a method
–
Check the result
■
■
Provides a mechanism to make assertions about the state of your objects
–
AssertTrue – fails if condition is false; passes otherwise
–
AssertEquals – fails if expected and actual objects are not equal
–
And others...
■
■
JUnit plugin is part of IBM Domino Designer ®
■
■
Build a suite of testcases to verify functionality doesn't change after code changes
■
■
Fixing defects can be expensive – save time & money by catching them with JUnit tests
■
20
20
21. XPages JUnit Framework
■
Provides predictable test cases that the XPages team have created to test the core
and extension library Java controls
■
■
Suite of test cases that can be applied to your library of controls
– Verify xsp-config files can be parsed
– Verify set methods correspond to property names
– Verify controls can be serialized
– And others...
■
■
Utility to generate .java files from .xsp files
■
■
Utilities for creating the JSF control tree and rendering HTML to the .xsp file
■
■
Extendable for your own specific test needs
■
■
Ideally requires some knowledge of the xsp-config file format
–
http://goo.gl/aX5x98
■
21
21
22. Testing a new Java control with XPages JUnit Framework
■
Create new test plugin that depends on JUnit and XPages JUnit Framework plugins as
well as core runtime plugins
■
■
Create a TestSuite class and specify test cases to run
■
■
Begin with the BaseGeneratePagesTest generating the .java files from .xsp files
■
■
Create a config.properties file in com.ibm.xsp.test.framework package
– target.library
– NamingConvention.package.prefix
– extra.library.depends.designtime.nonapplication
■
■
Create a xsp.properties in WEB-INF folder
■
■
Create JUnit tests that extend the base tests
■
■
22
Wiki Article - http://goo.gl/DIYsqZ
22
23. Example: Extended JUnit Tests
BaseLabelsLocalizedTest is for testing a predefined list of properties which should
always be localizable when defined in a control, namely:
– label
– title
– alt
– and others..
–
Add new “mainTitle ” property that we want to be localized
Add new “title” property that we don't want to be localized in this test case
Extend BaseLabelsLocalizedTest as new ExampleLabelsLocalizableTest
Add new localizable property (“mainTitle”) to list of properties to be tested as localizable
23
Change xsp-config to omit “title” property as localizable
23
25. Elements in my Java navigator in IBM Domino Designer
Custom XPages Library
com.example.xsp
Extended JUnit test
suite for your library
com.example.junit.tests
Custom selenium
test-suite for your library
SeleniumXPagesTestSuite
XPages JUnit test
Framework
com.ibm.xsp.test.framework
25
25
26. Pitfalls & Best Practices
Start to run JUnit tests from the beginning of development cycle
– even if you haven't written any yet!
–
Don't edit the test framework project itself.
– Create a subclass and update the behavior there
Always begin by generating .java files if testing .xsp files
//test that generates .java files from .xsp files
// at the start, as other tests depend on it to pass.
// - BaseGeneratePagesTest
suite.addTestSuite(BaseGeneratePagesTest.class);
Do not check in the contents of the gen/ folder to source control
If a test fails, read the test description and read the failure message
– Debug into source code itself (if needs be)
26
Learn from existing ExtLib tests in .control package available on OpenNTF
26
29. XPages Accessibility
Why should we worry about accessibility?
Millions of people worldwide live & work with a disability
IBM requirement
Extend market reach
Requirement for Government services
Promotes good Design Practices
Promotes better usability
–
29
33. XPages Accessibility
A brief overview
■
XPages must be compliant to WCAG 2.0 level A and level AA, and US Section 508
standards
■
XPage Web Apps
XPages in the Client (XPinC) Apps
■
IBM Web Accessibility Checklist
IBM Software Accessibility Checklist
■
http://goo.gl/YLPqm0
http://goo.gl/xDCrQF
■
■
XPages is the recommended accessible solution for IBM Domino Web Apps
■
There is no single solution but rather choose an accessible path
■
Make use of the tools, techniques and documentation available
–
33
A good starting point - http://www.w3.org/WAI/
34. XPages Accessibility
Supported Environments
■
34
In v9.0.1, the accessible path supported by XPages is:
–
Microsoft Windows 7
–
Mozilla Firefox 25
–
JAWS 14
–
English was chosen test language
–
Theme: “OneUI v2.1 Blue”
35. XPages Accessibility
■
WAI-ARIA standard
–
Accessible Rich Internet Applications
–
http://www.w3.org/WAI/intro/aria.php
■
■
Supplements HTML content
■
■
Increases accessibility of webpages
■
■
Some XPages controls are accessible “out-of-the-box”
■
■
35
Accessibility specific properties in IBM Domino Designer ®
–
e.g. 'role', 'title', 'description' properties
–
'attrs' property for adding additional aria attributes
37. XPages Accessibility
IBM Accessibility Verification Testing (AVT)
■
■
■
■
■
37
AVT1 - Automated Test Tools
–
Firefox plugin: Rational Policy Tester (RPT)
including Dynamic Assessment Tool
AVT2 - Manual Tests
–
Keyboard Navigation
–
Focus & Sequence
–
Visual formatting
●
Colour contrast
●
High contrast
●
Large font
–
Alternative content for audio/video
–
Error handling
AVT3 - JAWS
–
Screen Reader tool
38. XPages Accessibility
Guidelines & Best practices
Accessibility should begin at the 'Design' phase
■
■
–
–
–
■
■
Design your apps with accessibility in mind
Keep things simple & avoid over-complicating design
Use Accessible Controls where possible
–
See Control Reference sections of the Help User Guide to help choose controls
–
In 9.0.1, new accessibility properties have been added to some controls
■
■
Error Pages
–
38
Provide customized accessible XPage error
pages
39. XPages Accessibility
Guidelines & Best practices (cont.)
Using Partial Update
–
Using Events in your application
–
Ensure that the updated area/control is further down the page
Any mouse event must have a matching keyboard event
Using Access Keys in your application
–
–
Set accesskeys in IBM Domino Designer ®
Make the bindings unique and intuitive
Login Pages
–
39
Enable SSO on the Domino Server for accessible user
authentication
41. XPages Quality App Checklist
API + GUI Testing
– Selenium and JUnit
XPages Toolbox
– Profile your use cases
– Provides detailed analysis per request on CPU, Memory, Time costs
Adhere to the 10 golden rules of XPages Performance
– see Mastering XPages book for details
Preload commonly used apps where
possible
Base your installation on IBM XPages 9.0.1 !
41
44. Technical Education
IBM Press Books and eBooks
–
–
Three major publications over the past two years
All available for evaluation in the bookstore in the Solutions Expo
44
44
45. Technical Education
Coming very soon …
Mastering XPages 2nd Edition
–
–
–
–
Based on Notes/Domino 9.0.1
4 new chapters
●
Performance/Scalability
●
Mobile
●
Debugging
●
Application Layout
Comprehensive updates to all preexisting content
Hardcover
●
~500 pages of new content
●
~1200 pages total
45
45
46. More Information – General
For all information on XPages head to XPages.info
http://xpages.info/XPagesHome.nsf/Home.xsp
The Notes Domino Application Development Wiki
http://www-10.lotus.com/ldd/ddwiki.nsf
Free XPages snippets from the community
http://openntf.org/XSnippets.nsf/home.xsp
And don't forget the XPages books from IBM Press
http://www.ibmpressbooks.com/search/index.asp?query=xpages
Learning Roadmaps
–
–
New Developers
Experienced Developers
46
46
48. More Information – Summary
XPages.info – One Stop Shopping for XPages
http://xpages.info
XPages Forum – Got Questions, Need Answers?
http://xpages.info/forum
OpenNTF – Open Source Community
http://www.openntf.org
Domino Application Development Wiki
http://www.lotus.com/ldd/ddwiki.nsf
XPages Blog
http://xpagesblog.com
IBM Educational Offerings
http://www.ibm.com/software/lotus/training/n8deducationofferings.html
48
48
49. Engage Online
SocialBiz User Group socialbizug.org
– Join the epicenter of Notes and Collaboration user groups
Follow us on Twitter
– @IBMConnect and @IBMSocialBiz
LinkedIn http://bit.ly/SBComm
– Participate in the IBM Social Business group on LinkedIn:
Facebook https://www.facebook.com/IBMSocialBiz
– Like IBM Social Business on Facebook
Social Business Insights blog ibm.com/blogs/socialbusiness
– Read and engage with our bloggers
49
50. Merci
Danke
Buíochas
Gracias
Obrigado
Access Connect Online to complete your session surveys using any:
– Web or mobile browser
– Connect Online kiosk on site
Session ID: AD-208
Session Title: End-to-End Quality Processes for Top Notch XPages Apps
50
Grazie
53. Top 10 Golden Rules of XPages Performance
1. Use Partial Refresh whenever possible
2.
3.
4. Use Get instead of Post requests
5.
6.
7. Use readonly property on container type controls
8.
9.
10. Apply Partial Execution Mode to limit server side execution of an XPage
11.
12.
13. Use the dataCache property on Domino views to save on memory
1)
53
54. Top 10 Golden Rules of XPages Performance(contd)
6. Use viewScope instead of sessionScope and applicationScope
7. Avoid using rendered property to show/hide controls - use loaded property!
8. Avoid costly Notes/Domino API calls like getDocument*() in repeats and/or controls
9. Favour Disk Persistence
10. Always Enable Resource Aggregation
1)
54
56. Tuning, Profiling & Debugging
XPages Toolbox – Profiling Application
–
Runs on the Domino server or the Notes client
–
Provides detailed analysis per request on CPU, Memory, Time costs
IBM Domino Designer ® – Code Debuggers
–
ServerSide JavaScript Debugger
–
Java Debugger
Client/Server Logging
–
JVM Logging (can be controlled using the XPages Toolbox)
–
56
Request Introspection, print, _dump Techniques
–
Introspection techniques can be utilized using lifecycle PhaseListeners
–
print, _dump Techniques can be incorporated into application code
57. XPages Toolbox
XPages Toolbox – Profiling Application
–
Runs on the Domino server or the Notes client
–
An NSF needs to be installed on the Domino server/Notes client
–
A profiler jar file should be added to the JVM launch options
–
JVM Security policy updates
Profiles and Measures
–
CPU performance, Memory allocation, Threads, Sessions, Backend Activity
–
Profiling API can also be added into ServerSide JavaScript and/or Custom Java
57
Available from OpenNTF.org
–
Free open source project
–
Search for “XPages Toolbox” (Most recent version is 1.2)
60. XPages Toolbox
Generate a heap dump of the JVM running in the HTTP task
–
A button in the XPages profiler generates the heap dump
–
A new command from the Domino console
●
●
tell http xsp heapdump (triggers com.ibm.jvm.Dump.HeapDump())
tell http xsp javadump (triggers com.ibm.jvm.Dump.JavaDump())
Analyze the heap dump using the Eclipse memory analyzer
–
60
http://www.eclipse.org/mat/
70. XPages Example JUnit Suite
ExampleTestSuite to run the base set of tests from the XPages JUnit test framework
Base XPages
JUnit Framework
test
Extended
JUnit test
70
70
As a simple example, imagine you have created your XPages app, fully featured, looking great and ready to be releaseds out into the world. Now turn off your monitor. Would your app still be usable now? (next slide)
Consider that for many users with a visual disability they cannot see any of the visual aspects of your application. Instead they rely on screen readers to read out the content to them, and rely on only the keyboard for navigation, so no mouse interactions. To be accessible, your app must support screen readers and keyboard navigation.