Answer the question
In order to leave comments, you need to log in
Unit Tests and Asserts for Strings?
Gentlemen Programmers and Testers,
I have a very simple question, but very important for me:
Test:
If I enter the search query “Hello world” into Google,
then the title line of the search results should contain “Hello world”
How would you implement the line of the verification code (Assert ) for this test?
Answers are accepted in any programming language you know.
Thanks in advance and Happy New Year!
UPD.
Thanks for the replies, I would like to clarify the question: the actual page title bar should contain (contain) and not be equal to (equal) “Hello world”.
Those. the actual title line could be "Hello World - Google Search - Opera" and the test should pass with this line, but not with this one: "Hi Beer - Google Search - Opera".
Answer the question
In order to leave comments, you need to log in
response.should have_selector("title:contains('All your base are belong to us')")
PHPUnit:
$this->assertSelectEqual("title", "Привет мир", 1, file_get_contents("google.ru?q=Привет мир"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question