Добрый день. Совсем недавно,буквально вчера, мне пришлось столкнуться с Yii и функциональным тестированием.
php-файлы с тестами лежат удаленно, у нас git, Selenium RC у меня на компьютере.
При запуске тестов я получаю такую ошибку: "ERROR Server Exception: sessionId should not be null; has this session been started yet?",соотв. на стороне сервера то же самое.
Да и вот,что выводится дальше
~/.local/path/to/framework/test/CWebTestCase.php:61
~/.local/path/to/functional/MyProfile/profileSetUp.php:17
~/.local/path/to/functional/MyProfile/profileSetUp.php:17
В файле profileSetUp.php у меня только
class profileSetUp extends CWebTestCase {
public function setUp() {
parent::setUp();
$this->open("/profile");
}
}
Что мне нужно сделать,что SessionId не был null?
Selenium не получает SessionId
Автор patr14ek, 15 июн 2011 11:15
Сообщений в теме: 6
#1
Отправлено 15 июня 2011 - 11:15
ЕДРЕНАЯ КОНСОЛЬ ДЕЛАЕТ МЕНЯ СИЛЬНЕЙ!
#2
Отправлено 15 июня 2011 - 13:05
А что это за CWebTestCase? Вероятно, там в методе setUp должен быть вызов метода start() у селениума, но этого не случилось. Покажите реализацию CWebTestCase.
Алексей Баранцев
Тренинги для тестировщиков (тестирование производительности, защищенности, тест-дизайн, автоматизация):
Линейка тренингов по Selenium
Тренинги для тестировщиков (тестирование производительности, защищенности, тест-дизайн, автоматизация):
Линейка тренингов по Selenium
#3
Отправлено 16 июня 2011 - 05:34
Вот он. Никакие комментарии не убирала.
<?php /** * This file contains the CWebTestCase class. * * @author Qiang Xue <qiang.xue@gmail.com> * @link http://www.yiiframework.com/ * @copyright Copyright © 2008-2010 Yii Software LLC * @license http://www.yiiframework.com/license/ */ require_once('PHPUnit/Extensions/SeleniumTestCase.php'); /** * CWebTestCase is the base class for Web-based functional test case classes. * * It extends PHPUnit_Extensions_SeleniumTestCase and provides the database * fixture management feature like {@link CDbTestCase}. * * @author Qiang Xue <qiang.xue@gmail.com> * @version $Id: CWebTestCase.php 2497 2010-09-23 13:28:52Z mdomba $ * @package system.test * @since 1.1 */ abstract class CWebTestCase extends PHPUnit_Extensions_SeleniumTestCase { /** * @var array a list of fixtures that should be loaded before each test method executes. * The array keys are fixture names, and the array values are either AR class names * or table names. If table names, they must begin with a colon character (e.g. 'Post' * means an AR class, while ':Post' means a table name). * Defaults to false, meaning fixtures will not be used at all. */ protected $fixtures=false; /** * PHP magic method. * This method is overridden so that named fixture data can be accessed like a normal property. * @param string $name the property name * @return mixed the property value */ public function __get($name) { if(is_array($this->fixtures) && ($rows=$this->getFixtureManager()->getRows($name))!==false) return $rows; else throw new Exception("Unknown property '$name' for class '".get_class($this)."'."); } /** * PHP magic method. * This method is overridden so that named fixture ActiveRecord instances can be accessed in terms of a method call. * @param string $name method name * @param string $params method parameters * @return mixed the property value */ public function __call($name,$params) { if(is_array($this->fixtures) && isset($params[0]) && ($record=$this->getFixtureManager()->getRecord($name,$params[0]))!==false) return $record; else return parent::__call($name,$params); } /** * @return CDbFixtureManager the database fixture manager */ public function getFixtureManager() { return Yii::app()->getComponent('fixture'); } /** * @param string $name the fixture name (the key value in {@link fixtures}). * @return array the named fixture data */ public function getFixtureData($name) { return $this->getFixtureManager()->getRows($name); } /** * @param string $name the fixture name (the key value in {@link fixtures}). * @param string $alias the alias of the fixture data row * @return CActiveRecord the ActiveRecord instance corresponding to the specified alias in the named fixture. * False is returned if there is no such fixture or the record cannot be found. */ public function getFixtureRecord($name,$alias) { return $this->getFixtureManager()->getRecord($name,$alias); } /** * Sets up the fixture before executing a test method. * If you override this method, make sure the parent implementation is invoked. * Otherwise, the database fixtures will not be managed properly. */ protected function setUp() { parent::setUp(); if(is_array($this->fixtures)) $this->getFixtureManager()->load($this->fixtures); } }
ЕДРЕНАЯ КОНСОЛЬ ДЕЛАЕТ МЕНЯ СИЛЬНЕЙ!
#4
Отправлено 20 июня 2011 - 05:24
Что, правда никто не знает? =//
ЕДРЕНАЯ КОНСОЛЬ ДЕЛАЕТ МЕНЯ СИЛЬНЕЙ!
#5
Отправлено 20 июня 2011 - 08:10
"ERROR Server Exception: sessionId should not be null; has this session been started yet?" Ну я сталкивалась с таким иногда. Ошибку лечило только время =) Либо перегрузка машины. И перегрузка всего возможного.
Но не было никогда такого, чтобы такое было постоянно и не лечилось 
Я в php не очень понимаю, вы не передаете случайно пустую сессию? =)
А если просто зарекродить и вставить в ИДЕ то будет такая же ошибка?


Я в php не очень понимаю, вы не передаете случайно пустую сессию? =)
А если просто зарекродить и вставить в ИДЕ то будет такая же ошибка?
#6
Отправлено 20 июня 2011 - 08:20
Почему не знает? Я же написал -- "в методе setUp должен быть вызов метода start() у селениума", а его там нет. Не открывается сессия, поэтому и null вместо sessionId.
В документации к PHPUnit_Extensions_SeleniumTestCase чётко написано: "Unlike with the PHPUnit_Framework_TestCase class, test case classes that extendPHPUnit_Extensions_SeleniumTestCase have to provide a setUp() method. This method is used to configure the Selenium RC session."
http://www.phpunit.d...eleniumtestcase
Либо в фикстурах должен быть запуск селениума, проверьте, есть ли там везде, где надо, вызов метода start()
В документации к PHPUnit_Extensions_SeleniumTestCase чётко написано: "Unlike with the PHPUnit_Framework_TestCase class, test case classes that extendPHPUnit_Extensions_SeleniumTestCase have to provide a setUp() method. This method is used to configure the Selenium RC session."
http://www.phpunit.d...eleniumtestcase
Либо в фикстурах должен быть запуск селениума, проверьте, есть ли там везде, где надо, вызов метода start()
Алексей Баранцев
Тренинги для тестировщиков (тестирование производительности, защищенности, тест-дизайн, автоматизация):
Линейка тренингов по Selenium
Тренинги для тестировщиков (тестирование производительности, защищенности, тест-дизайн, автоматизация):
Линейка тренингов по Selenium
#7
Отправлено 05 июля 2011 - 12:39
спасибо, разобралась. В setUp были лишние строчки.
ЕДРЕНАЯ КОНСОЛЬ ДЕЛАЕТ МЕНЯ СИЛЬНЕЙ!
Количество пользователей, читающих эту тему: 1
0 пользователей, 1 гостей, 0 анонимных