I'm using selenium RC with 开发者_Go百科PHPunit and i have this problem. I'm trying to do assertEqual but this is the result:
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
abc
def
The step line:
$this->assertEquals("abc\ndef", $this->getValue("text"));
and "text" is "abc\ndef".
In firefox it's working ok. The problem is only with IE. In the result he doesn't tell me what is not equal..
There's most likely a carriage return (\r
) in there which PHPUnit's string diff output isn't displaying. Use addslashes()
or serialize()
to display the hidden characters.
$this->assertEquals(addslashes("abc\ndef"), addslashes($this->getValue("text")));
I add an answer for the people that arrive here with Google.
You can do like that too:
$this->assertEquals(preg_split('/\r\n|\r|\n/', "abc\ndef"), preg_split('/\r\n|\r|\n/', $this->getValue("text")));
or
// Note the return line in the PHP file without any space at the begining
$this->assertEquals(preg_split('/\r\n|\r|\n/', 'abc
def'), preg_split('/\r\n|\r|\n/', $this->getValue("text")));
精彩评论