Cakephp 使用assertText()函数需要更清晰的说明吗?
我已经为我的应用程序编写了自动化测试用例。下面是我用于web测试的示例代码 类UserWebTestcase扩展了CakeWebTestCase{Cakephp 使用assertText()函数需要更清晰的说明吗?,cakephp,simpletest,Cakephp,Simpletest,我已经为我的应用程序编写了自动化测试用例。下面是我用于web测试的示例代码 类UserWebTestcase扩展了CakeWebTestCase{ var $name='UserWebTestcase'; function testLogin001() { //Test if new user registration form works as intended when all the inputs are given properly. $this->get(Con
var $name='UserWebTestcase';
function testLogin001()
{
//Test if new user registration form works as intended when all the inputs are given properly.
$this->get(Configure::read('url'));
$this->setField('email', 'admin45@gmail.com');
$this->setField('tmppassword', 'admin123');
$this->setField('password_confirm', 'admin123');
$this->clickSubmit('SUBMIT');
$this->assertText('login');
}
}
在测试用例中,它总是给出false,即使字段的输入是正确的
失败
C:\xamplite\htdocs\spotchase\app\tests\cases\models\user.test.php->UserWebTestcase->testLogin001。
在使用assertText方法时,我真的很困惑。我应该如何使用此assertText方法以及应该向此方法传递哪些参数。请帮助。这不是一个cakephp方法,而是一个最简单的方法 下面是实际的方法
/**
* Will trigger a pass if the text is found in the plain
* text form of the page.
* @param string $text Text to look for.
* @param string $message Message to display.
* @return boolean True if pass.
* @access public
*/
function assertText($text, $message = '%s') {
return $this->assert(
new TextExpectation($text),
$this->_browser->getContentAsText(),
$message);
}
因此,它似乎只是查找页面中的实际文本,而不是按钮或其他元素。也许“欢迎鲍勃”会是一个更好的搜索