Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Dear Developers and QA,

I would like to ask a very simple question, but it is very important for me.

Please, consider the following test:

When I enter the search phrase “Hello World” into the Google Search box Then the Google’s search page title should contain the string “Hello World”

How would you implement this verification (assertion) in the unit test code? Please, post your code samples in any programming languages you like.

Thanks in advance, Dmitry

share|improve this question
2  
There are a lot of ways to implement this, from directly calling the page using HttpWebRequest to using an automation framework like Selenium to mimic user interaction on the site itself. Your question is very open ended and generic and doesn't really give a lot of details about what you are trying to accomplish. More details would be great. What is the point of this exercise? –  Sam Woods Dec 30 '11 at 21:10
    
Hi Sam, I need some statistics on how the developers and automated testers are implementing this case. It is not about any technical details, so, for instance, you already have a variable expectedSubstring = “Hello World” and actualTitle = “hello world – Google Search”. –  Dmytro Zharii Jan 1 '12 at 18:39

1 Answer 1

I find it hard to believe that this is a unit test (unit being single function/method).

This seems more like a basic functional test through the user interface.

As Sam says there are many ways this can be done and different levels to "intercept" or get the "result."

WRT language, C# and Java have a method called string.Contains, and C++ has string.find. I am sure other languages have similar methods.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.