QSIC 2012 Presentation Automated Testing of Web
QSIC 2012 Presentation Automated Testing of Web
Browser side:
Hundreds/thousands of HTML elements. Dynamic -- always changing at runtime, frequently asynchronously.
Ad-hoc and manual system/integration testing. Inefficient automated testing through the user interface:
Hard to maintain due to rapid changes. Focused on observing the browser to the exclusion of other application tiers.
WebTestingExplorer Advantages
Efficiently test through the user interface. Test like a real user. Don't miss integration issues and things that are hard to observe.
Behind the scenes in the browser. Or on other application tiers.
Design: Testability
Optimize for the case where testers have detailed technical knowledge of the application-under-test.
And can improve testability (such as by adding unique id's).
WebTestingExplorer Workflow
Two Complementary Phases: 1. Exploratory
Incrementally searches for new application states. Writes out new test cases and oracles. Can search for bugs.
2. Replay
Executes tests generated by the Exploratory phase. For regression testing. A/B, comparison of actual and expected states.
Terminology
Element: An HTML element in the browser.
Actionable Element: An element that the application's end-user can interact with. Stateful Element: An element that the tester wants to examine for state changes. State: An abstraction of the current state of the web application, as defined by the tester. Action: Performed on an element to cause something to happen in the web application. Action Sequence: An ordered list of actions. Test Case: An action sequence (deemed interesting on the basis of state change) that is saved for future replay.
Workflow: Exploratory
Iteratively and systematically moving through the web application via the user interface.
Monitors for different types of bugs. Generates increasingly-long and sophisticated test cases (and oracles) for later replay.
State: Definition
Def: An abstraction of the current state of the web application, customizable by the tester. WebTestingExplorer has a rich and extensible notion of state. Can theoretically include a combination of:
Web browser state (HTML, DOM, cookies, ...) Web server state (session data, variables, ...) Database state (persistent application data)
Exploration Algorithm
Execute IAS AS: action sequence AI: actionable element IAS: initial action sequence SS: start state FS: final state
Extend IAS
DEQUE
No
Extend AS
Exploration Algorithm
Execute IAS <IAS1, AI1>,<IAS1, AI2> ,....,<IAS1, AIn> <IAS2, AI1>,<IAS2, AI2> ,....,<IAS2, AIn> ... <IASm, AI1>,<IASm, AI2> ,....,<IASm, AIn> Extend IAS
DEQUE
No
Extend AS
Oracles: Framework
WebTestingExplorer includes an oracle framework and some pre-defined oracles. Can be used to detect bugs during Exploratory and Replay phases. Oracles for regression testing can be generated during Exploratory phase, used during Replay phase.
May leverage initial and final state.
Oracles: Examples
HttpResponseOracle: Checks for allowed and disallowed HTTP response codes. JSErrorCollectorOracle: Looks for Javascript runtime errors. FinalStateCheckOracle: Uses initial and final state for regression testing. Also:
The framework allows testers to plug in custom oracle implementations.
Replayer is configured with the FinalStateCheckOracle. Replayer replays the test case. At the end, a state snapshot is taken and compared to the final state saved in the test case. If they are different, a failure is recorded.
Configuration
WebTestingExplorer is highly configurable for both phases (Exploratory and Replay). Can limit the state space and restrict the action sequences to be explored. Examples:
Skip exploring common header and footer elements on the page. Exclude ads from the Actionable and Stateful elements. In an industrial web application, we have observed that we can generate interesting test cases by checking just two Stateful elements.
Configuration Points
Selectors for Actionable and Stateful web elements. Pre-packaged and custom Oracles. Action sequence filters to eliminate redundant or uninteresting exploration paths. Example: MaxRepeatedActionSequenceFilter eliminates action sequences that repeat the same action more than a set number of times. Action generators to create custom actions on specific elements. Action sequence prioritizer for test case prioritization during exploration. Custom wait conditions to increase stability while executing an action sequence.
new TagActionGeneratorConfig("a") { @Override public Set<Action> generateActions(WebElementWithIdentifier elementWithId) { Set<Action> actions = Sets.newHashSet(); String href = elementWithId.getElement().getAttribute("href"); if (href != null && href.startsWith("javascript:")) { actions.add(new ClickAction(elementWithId.getIdentifier())); } return actions; } }
Related Work
Browser automation frameworks (Selenium, WebDriver).
Allow testers to automate test cases of their own design.
Future Work
Parallel exploration. Code coverage integration. Evaluate the effectiveness of different state abstractions. Integrated state from multiple tiers of the web application. Industrial applications and studies.
Questions?