In the previous blog, we were introduced to the concept of developing web applications using next generation client side RIA technologies like AngularJS/BackboneJS. This post introduces us to the latest technology on automation of testing such applications. The tools mentioned are in focus due to their proven track record in working as an integrated unit though other similar tools too can be worked out.
End to End testing (e2e)
Unit testing is used to test each smaller functional level code separately without any integration points. With e2e testing, focus is more on integrated end user functionality.
Automated Web Application Testing Tools
For long, Selenium has been a leading technology to automate testing of web applications with in-browser as well as remote unit testing frameworks. It automates browsers, in other words what we do in browsers like page navigation, button clicks, form input fields entries, submitting forms, etc. can be automated using Selenium. Selenium browser specific in-browser tool can be used to record a test in browser and rerun the saved test.
But, it has had its share of browser compatibility issues such as difficulty in accessing dynamic HTML/DOM elements served by RIA, etc.
WebDriver is an improvement over selenium in a sense that it introduces a new way to interact with the browsers and has minimal compatibility issues. It supports most of the programming languages viz, Rbuy, Python, Java etc.
WebDriverJS is different from other tools as it is asynchronous and tests are handled by what is known as Promises. Promises, in layman terms, are similar to callback mechanism to handle asynchronous responses.
It however is a bit difficult to debug when accessing page elements because of its asynchronous nature. We then have to depend on native WebDriverJS function calls as workaround. It can run individual e2e test cases from command prompt, but needs Jasmine to run all test cases in a single execution.
Although Jasmine is capable of running test suites, Grunt leverages the role of task runner by handling starting and stopping of testing and offers more configuration support, minifications, etc.
Selenium + WebDriverJS + Jasmine + Protractor + Grunt – An ecosystem
Selenium and WebDriver takes care of local and server side APIs for driving a browser and handling the DOM and page loads to run tests on website. The ecosystem works as:
- Selenium standalone server is set to listen on a port for API calls.
- A browser session is started on test startup.
- WebDriver is loaded to control a particular browser session.
- Support multiple browser sessions and allow browser sessions to load site from remote server.
- Tests are then executed using the Jasmine Runtime Environment.
This ecosystem avoids the need for repetitive manual e2e testing for each functional change or enhancement and thus saves precious development time. It can be wired to run in Build automation where it can execute a nightly suite of e2e and unit tests and report errors thus saving developer time.
Test reports can be generated by integrating Protractor with Jasmine Reporter API. The report is usually generated in XML format and can be converted to HTML using XSLT.
Error: Contact form not found.