XPages build automation and testing

  • View

  • Download

Embed Size (px)

Text of XPages build automation and testing

  1. 1. www.ics.ug #icsug Let the machines do their work and have good night sleep Martin Pdn, @mpradny Martin Jinoch, @mjinoch
  2. 2. www.ics.ug #icsug Agenda Introduction Testing and Domino Demo 1 Build Automation Demo 2 Discussion
  3. 3. www.ics.ug #icsug About us Martin Jinoch jinoch@gmail.com @mjinoch http://jinoch.cz Martin Pdn pradny@pradny.com @mpradny http://pradny.com
  4. 4. www.ics.ug #icsug Why building and testing matters? Code changes break existing features Developers step on each others code Infrastructure changes break apps Application works only for happy-path scenarios
  5. 5. www.ics.ug #icsug Testing Unit testing Integration testing UI testing
  6. 6. www.ics.ug #icsug Domino Problems Tight data and code integration Unstructured code Dependency on Notes C runtime No light in-memory option
  7. 7. www.ics.ug #icsug Solutions Write apps with testing in mind Separate code and data Source Control Build automation
  8. 8. www.ics.ug #icsug Tools XPages with Junit org.openntf.junit.xsp JUnit/TestNG in your ODS project Easy test of non-XPages code Mock domino classes EasyMock, PowerMock UI testing Selenium
  9. 9. www.ics.ug #icsug Local testing setup Change ODP to Java project Maks Zhuk - http://mzhuk.blogspot.com/ Manually edit .project file Add Code/Java as Source Folder Add Local directory Create Java project with tests Add mocking library (optional)
  10. 10. www.ics.ug #icsug Local testing setup - details http://mzhuk.blogspot.com/2014/02/unit-tests-for-lotus-domino- applications.html Snippet from .project org.eclipse.jdt.core.javabuilderorg.eclipse.jdt.core.javanature
  11. 11. www.ics.ug #icsug
  12. 12. www.ics.ug #icsug Demo 1 - scenario XPages application fake CMS with articles Computation of article expiration date based on article type logic in Java 3 different types of definitions and tests Hard-coded in Java In a document In a view
  13. 13. www.ics.ug #icsug Demo
  14. 14. www.ics.ug #icsug Automation Maven, Ant, Gradle, .. Describe and run steps to get final deliverable Jenkins, Teamcity, Bamboo, Continuous integration Check-out source code Run periodical builds and much more
  15. 15. www.ics.ug #icsug Headless designer Command line invocation of Domino Designer Create NSF from On Disk Project Enable/Disable plugins New feature in 9.0.1 http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Headless_Designer_Wiki notes.ini parameter - DESIGNER_AUTO_ENABLED=true ID without password
  16. 16. www.ics.ug #icsug Headless designer invocation Manually Single command command line designer -RPARAMS -vmargs - Dcom.ibm.designer.cmd=[clean],[exit],[file name],[job name],[file path],[file name] Command file designer -RPARAMS -vmargs - Dcom.ibm.designer.cmd.file=[path to command file]
  17. 17. www.ics.ug #icsug Headless designer wrappers Maven Christian Gdemann Included in public Maven repository Options to install Designer plugins https://github.com/OpenNTF/BuildAndTestPattern4Xpages Ant Cameron Gregor Additional tasks for NSF manipulation Uses Java Native Interface https://github.com/camac/BuildXPages Gradle - Martin Pradny not maintained https://bitbucket.org/pradnik/gradledominoplugin
  18. 18. www.ics.ug #icsug Headless designer - Maven domino-nsf${basedir}/on-disk-projectorg.openntf.mavenheadlessdesigner-maven-plugin1.2.0true From:https://github.com/OpenNTF/BuildAndTestPattern4Xpages/blob/master/testpatterns/org.openntf.junit.xs p.parent/org.openntf.junit.odp/pom.xml
  19. 19. www.ics.ug #icsug Why Maven Standard in XPages community OSGi friendly with Tycho plugin IBM released Update Site on OpenNTF.org IBM Domino Update Site for Build Management http://openntf.org/main.nsf/project.xsp?r=project/IB M%20Domino%20Update%20Site%20for%20Build%20 Management Allows building Extension Libraries
  20. 20. www.ics.ug #icsug Jenkins (teamcity, bamboo,..) Continuous Integration Integrate with SCM (Git, SVN, ) Trigger build, push/pull, Run build, Run tests Report errors Deploy to production Extensible with plugins
  21. 21. www.ics.ug #icsug Jenkins https://jenkins-ci.org/ Bamboo https://www.atlassian.com/software/bamboo TeamCity https://www.jetbrains.com/teamcity/
  22. 22. www.ics.ug #icsug Selenium Web browser automation (Firefox, Chrome, IE,) Selenium IDE (Firefox) Record tests Replay tests Export (Java, C#, ruby, Python, ..) Selenium server, grid Run tests on remote machines http://www.seleniumhq.org
  23. 23. www.ics.ug #icsug Demo 2 - scenario Same application as in Demo 1 Maven driven build on Jenkins Compile and run tests using Tycho/OSGi Build NSF from ODP Maven plugin Run Selenium tests Copy NSF to server Ant task Load data calling an Agent using URL
  24. 24. www.ics.ug #icsug Demo 2 - Environment
  25. 25. www.ics.ug #icsug Demo 2
  26. 26. www.ics.ug #icsug Demo 2 - notes https://bitbucket.org/pradnik/ics.ug-demo mvn clean verify P complete Jenkins running as a service Allow to interact with desktop SCM Poll since running as local VM (not optimal) Maven settings using Config File Provider plugin for Domino Update Site for Designer data directory Profile for just testing Some properties are hard coded in pom.xml
  27. 27. www.ics.ug #icsug Demo 2 settings.xml org.openntf.mavenmainfile:///Z:/Share/DominoUpdatsitec:/IBM/Notes/Data/
  28. 28. www.ics.ug #icsug Demo 2 Jenkins configuration
  29. 29. www.ics.ug #icsug Trade-offs What to automate Cost of test maintenance vs. manual execution False feeling of security
  30. 30. www.ics.ug #icsug Conclusion Testing is good Test from very start Helps cleaner code Helps cleaner UI Path to Continuous Delivery Code quality automated analysis SonarQube - http://www.sonarqube.org/
  31. 31. www.ics.ug #icsug Questions?
  32. 32. www.ics.ug #icsug Thank you!