Wrapping up Maven & JS best practices to achieve smooth Enduser testing
The Apache Syncope Enduser is essentially provided as a full-working template, with declared purpose of being extremely customizable and adaptable to the various needs of the domains in which it will be deployed, in terms of UI, client-side and server-side behavior.
While developing the Enduser application, we faced the issue of defining an easy way to test its front-end features; in other words, we wanted to provide the Maven-driven build process with everything a developer needs to perform end-to-end testing.
The good news is that AngulaJS is shipped with its own testing framework, Protractor, an e2e testing framework for web-based application written in Angular: tests are executed in a real browser, simulating user interaction.
Protractor, which will anyway require several dependencies, runs on top of NodeJS, that needs to be installed upfront. Moreover, Protractor requires a webdriver, acting as a mediator to access browsers API; we have finally chosen the implementation provided by Selenium.
More requirements are involved: in some environments, like as Jenkins and Travis CI, simply there is no UI: what if protractor asks to interact with Firefox? Tests will not be able to run, breaking the build. Luckily, in the past years headless browsers have been developed, which don’t need any UI! For this role, we have finally chosen PantomJS.
As you can understand, Protractor needs a sort of environment to be prepared and made available, including dependency resolution, on-the-fly during the Apache Syncope (Maven-driven) build process!
To close the loop, Maven installs PhantomJS, Node and Protractor: once everything has been set up, end-to-end tests are finally executed. Moreover, once everything is up and running, e2e tests can be re-executed without need of restarting anything, speeding up the test development process.
If interested in the details, you can take a look at how the Maven POM file is configured with some plugins to achieve such results.
In the next post I will show in practice as the whole process works, how tests are run and even how to write a new test case. Stay tuned!