Posted by Markus Clermont, John Thomas
This is the first in a two part blog series titled 'Taming the Beast: How to test AJAX applications". In this part we discuss some philosophies around web application testing and how it should be done the 'right' way. In part 2, we walk through a real example of designing a test strategy for an AJAX application by going 'beyond the GUI.'
Background
Typically we address the problem of testing an AJAX application through a plethora of big end-to-end tests and (hopefully) high unit-test coverage. Here we outline the main problems with this approach and demonstrate an effective testing strategy for a sample GWT-based application which goes beyond "testing just through the GUI."
Problems with GUI-only testing
- is expensive (takes long to write the tests and execution is resource-intensive)
- gives limited insight into the system
- often take only the 'happy paths' into account
- combines multiple aspects in a single test
- is slow and brittle
- needs a lot of maintenance
- is hard to debug
And while unit tests don't suffer from many of these problems, they alone are not sufficient mainly because they:
- give little insight how the components interact with each other
- don't give confidence that the business logic and functionality of the system meets the requirements
Solution
Although there is no 'one size fits all' solution, there are some basic principles we can use to solve the testing problem for web applications:
- Invest in integration tests (identify the smallest sub-system)
- Separation of Concerns (don't do the set-up through the interface you are testing)
- Test each interface separately (mock out everything that you are not testing)
- Consider dependencies in production (figure out how dependencies can fail, and test that)
- Use a mix of strategies and tools. There is no silver bullet.
- And no... you cannot scrap all of your end-to-end tests
A recipe for testing goodness
Using the principles above we can build up a recipe for testing web applications. In the second part of our blog we will walk through each of these steps for a real web application.
- Explore the system's functionality
- Identify the system's architecture
- Identify the interfaces between components
- Identify dependencies and fault conditions
- For each function:
- Identify the participating components
- Identify potential problems
- Test in isolation for problems
- Create a 'happy path' test
End note: value of a test
A question commonly asked by developers when writing tests is, "is this really worth my time?" The short answer is "always!". Since fixing a bug is way more expensive than preventing it in the first place, writing good tests is always worth the time.
While there are many different classifications of tests, the most common way of classifying them is based on their size and the areas of a product they test. Each test answers specific questions about the product:
- Unit test: is the method fulfilling its contract?
- Small integration test: Can two classes interact with each other?
- Medium integration test: Is a class interacting properly with all its dependencies? Does it anticipate and handle errors correctly? Are the needed functions exposed on an API/GUI?
- Sub-system test: Can two sub-systems interact with each other? Does one of them anticipate all errors of the other and does it deal with them appropriately?
- System test: Does the entire system behave as expected?
In the next episode we will walk through the recipe proposed above using a real web application. Permalink | Links to this post |
8 comments:
Somehow, personally I am disppointed with Part 1 - that aims at explaining philosophies around web application testing in "right" way and ended up in making very generic statements/suggestions like
(Looked more like a FAQ about Testing (not even web app testing))
" Explore the system's functionalityIdentify the system's architectureIdentify the interfaces between componentsIdentify dependencies and fault conditionsFor each function:Identify the participating componentsIdentify potential problemsTest in isolation for problemsCreate a 'happy path' test
Invest in integration tests (identify the smallest sub-system)Separation of Concerns (don't do the set-up through the interface you are testing)Test each interface separately (mock out everything that you are not testing)Consider dependencies in production (figure out how dependencies can fail, and test that)
May be articulation was not appropriate ...
Hope to see something really "thought" provoking in Part 2 (in line with what techies normally expect with Google)
Shrini
Interesting. I look forward to seeing more regarding your example application and how to test it.
Could you eventually provide a downloadable pdf document as you did with previous posts :) ?
Thanks
Interesting post, and yes we certainly agree that AJAX web applications can be quite difficult to test.
But the picture you seem to paint is rather bleak, and it need not be.
The situation for testing an AJAX application is actually easier than you may think, provide that you have the right tools and by using their underlying technology base can "do the right things" at the right time.
* To overcome the expense of creating functional tests it makes sense to have a good test recorder, which takes away most of the pain of creating tests.
* Tests can be brittle, so you should have some kind of functional test playback feature than automatically adapts the bahavior of the playback engine to overcome inconsequential changes in the pages tested.
* To split out tests of individual features you need some kind of CallScript capability that lets you organize your tests easily into groups of related functionality.
But you are dealing with AJAX -- and it seems that you left out the most important aspect of all: test synchronization. Tests of AJAX type applications scream out for playback synchronization -- but not by adding Waits or Delays or Sleeps that never work in practice. There has to be a way built into your playback engine to interact with the DOM of the page and sense when it is OK to continue playback.
We believe if you have the right facilities in the test engine the functional testing job for an AJAX application can produce very good results.
When is Part 2 coming ...?
Waiting ...
Shrini
It might also be good to mention other test categories as well that relate to this such as: security, performance, etc... I look forward to Part II.
網頁設計,情趣用品店,情趣用品專賣網
A片,色情A片,免費A片,成人影片,色情影片,a片免費看,情色貼圖,情色文學,情色小說,色情小說
AV,AV女優
辣妹視訊,美女視訊,視訊交友網,視訊聊天室,視訊交友,視訊美女,免費視訊,免費視訊聊天,視訊交友90739,免費視訊聊天室,成人聊天室,視訊聊天,視訊交友aooyy
哈啦聊天室,辣妺視訊,A片,色情A片,視訊,080視訊聊天室,視訊美女34c,視訊情人高雄網,視訊交友高雄網,0204貼圖區,sex520免費影片,情色貼圖,視訊ukiss
希望大家都會非常非常幸福~
「朵朵小語‧優美的眷戀在這個世界上,最重要的一件事,就是好好愛自己。好好愛自己,你的眼睛才能看見天空的美麗,耳朵才能聽見山水的清音。好好愛自己,你才能體會所有美好的東西,所有的文字與音符才能像清泉一樣注入你的心靈。好好愛自己,你才有愛人的能力,也才有讓別人愛上你的魅力。而愛自己的第一步,就是切斷讓自己覺得黏膩的過去,以無沾無滯的輕快心情,大步走向前去。愛自己的第二步,則是隨時保持孩子般的好奇,願意接受未知的指引;也隨時可以拋卻不再需要的行囊,一路雲淡風輕。親愛的,你是天地之間獨一無二的旅人,在陽光與月光的交替之中瀟灑獨行.............................................................................................................有時,你覺得痛。胃痛的時候,接受它,承認這個疼痛是你的身體的一部份,與它和平共處。心痛的時候,接受它,承認這個經驗是你的生命的一部份,與它和平共處。抗拒痛的存在,只會讓它更要證明它的存在,於是你就更痛。所以,.無論你有多麼不喜歡痛的感覺,還是要接納這個痛的事實。與你的痛站在同一邊,不逃避,不閃躲,不再與你的痛爭執,如此,你的痛才會漸漸不再胡鬧,才會乖乖平息下去。.................心願-你許下了一個心願,你閉上眼睛,在冥想之中把這個心願交託宙給宇整個讓宇宙推動它全部的力.量去執行.,你看見星球與星球的引力牽繫著彼此,你聽見虛空與虛空.唱裡著和妙美的聲音,為了你的心願,整個宇宙正在相互傳遞,然後你放下了心願,不僅是放下,最好你還把你的心願忘記,唯有如此,它才能脫離你,發展它自己,
當它在宇宙的遊歷結束之後,它自然會來到你身邊,以你曾經希望的方式回應你,許下,只是讓它發生,放下,才是讓>它實現,你的心願使你懂得不能執著的奧秘...................
Post a Comment