Giter VIP home page Giter VIP logo

codeception's Introduction

Stand With Ukraine

Codeception

Latest Stable Total Downloads StandWithUkraine Build status

Modern PHP Testing for everyone

Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely new way of writing acceptance, functional and even unit tests.

Contributions

At Codeception we are glad to receive contributions from the community. If you want to send additions or fixes to the code or the documentation please check the Contributing guide.

At a Glance

Describe what you test and how you test it. Use PHP to write descriptions faster.

Run tests and see what actions were taken and what results were seen.

Sample test

$I->amOnPage('/');
$I->click('Pages');
$I->click('New');
$I->see('New Page');
$I->submitForm('form#new_page', ['title' => 'Movie Review']);
$I->see('page created'); // notice generated
$I->see('Movie Review','h1'); // head of page of is our title
$I->seeInCurrentUrl('pages/movie-review'); // slug is generated
$I->seeInDatabase('pages', ['title' => 'Movie Review']); // data is stored in database

For unit testing you can stay on classic PHPUnit tests, as Codeception can run them too.

Installation

Composer

php composer.phar require "codeception/codeception"

TODO: Document how to install the modules, e.g.

php composer.phar require "codeception/module-phpbrowser"

Phar

Download codecept.phar

Copy it into your project.

You can also make Codeception an executable and it put it into your $PATH, for instance:

wget https://codeception.com/codecept.phar

chmod +x codecept.phar

sudo mv codecept.phar /usr/local/bin/codecept

You can then run Codecept in the command line using: codecept bootstrap, codecept run, etc

Run CLI utility:

php codecept.phar

See also Installation | QuickStart

Getting Started

After you successfully installed Codeception, run this command:

codecept bootstrap

This will create a default directory structure and default test suites.

Documentation

View Documentation

The documentation source files can be found at https://github.com/Codeception/codeception.github.com/tree/master/docs/.

License

MIT

codeception's People

Contributors

akovardin avatar alexkunin avatar allmyitjason avatar arhell avatar ashnazg avatar davertmik avatar dizzy7 avatar edno avatar enumag avatar exorus avatar fntm avatar gimler avatar janhenkgerritsen avatar korotovsky avatar naktibalda avatar oneeyedspacefish avatar piccagliani avatar ragazzo avatar raistlin avatar samdark avatar sammousa avatar sergeyklay avatar slamdunk avatar splinter89 avatar tavoniievez avatar thomaslandauer avatar tiger-seo avatar trustnik avatar tumtum avatar zbateson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeception's Issues

Exception thrown Symfony\Component\CssSelector\Exception\ParseException: Unexpected symbol: ! at 7

I Found this durning my test:
Couldn't generate link to set up new password (User_RegisterCept.php)
Exception thrown Symfony\Component\CssSelector\Exception\ParseException:
Unexpected symbol: ! at 7
Stack trace:
#1 tokenizeSymbol /usr/lib/php/pear/Symfony/Component/CssSelector/Tokenizer.php:99
#2 tokenize /usr/lib/php/pear/Symfony/Component/CssSelector/CssSelector.php:97
#3 parse /usr/lib/php/pear/Symfony/Component/CssSelector/CssSelector.php:65
#4 toXPath /usr/lib/php/pear/mink/src/Behat/Mink/Selector/CssSelector.php:27
#5 translateToXPath /usr/lib/php/pear/mink/src/Behat/Mink/Selector/SelectorsHandler.php:94
#6 selectorToXpath /usr/lib/php/pear/mink/src/Behat/Mink/Element/Element.php:67
#7 findAll /usr/lib/php/pear/mink/src/Behat/Mink/Element/Element.php:57
#8 find /usr/lib/php/pear/Codeception/src/Codeception/Util/Mink.php:149
#9 findEl /usr/lib/php/pear/Codeception/src/Codeception/Util/Mink.php:131

This is my test:

$I = new WebGuy($scenario);
$I->wantTo('generate link to set up new password');
$I->amOnPage('/user');
$I->click('Password recovery');
$I->seeInUrl('/user/index/password-recovery');
$I->amOnPage('/user/index/password-recovery');
$I->fillField('username', '[email protected]');
$I->click('Recover');
$I->see('Recovery password e-mail send to: [email protected]');

Is it some bug in Codeception? Or I dont get something?

Codeception exit code breaking CI Automation on 'failed tests'

In Codeception/Command/Run::execute() on line 66:
if ($codecept->getResult()->failureCount() or $codecept->getResult()->errorCount()) exit(1);

Codeception is exiting with a status code of "1" whenever any of the tests fail. This confuses CI frameworks like Bamboo (and presumably jenkins) into thinking that codeception itself failed.

Ideally even when errors have been detected the exit code should still be "0" so that CI frameworks know that Codeception executed the tests correctly, and then parse the results to see which tests failed or succeeded.

Thanks :)

[dont]see в регексп или хотя бы /i режиме

Банальное $I->dontSee('Ошибка') не выскочит, если в тексте есть слово ошибка. Хотелось бы чтобы метод умел не учитывать регистр или принимать на вход регулярки.

Symfony 1

class_name: TestGuy
modules:
enabled:
- Symfony1
- Selenium
- WebHelper
- Doctrine1
config:
Symfony1:
app: frontend
Selenium:
url: 'http://site.ru'
browser: firefox
delay: 750

PHP Fatal error: Cannot use object of type Closure as array in /var/www/ch/lib/vendor/symfony/lib/autoload/sfAutoloadAgain.class.php on line 72

Fatal error: Cannot use object of type Closure as array in /var/www/ch/lib/vendor/symfony/lib/autoload/sfAutoloadAgain.class.php on line 72

Zombie JS alternative Node JS script

Hi, I'm using Zombie JS and have run into a problem where I need to customize the Node startup script.

Can you please show me an example of how to do this?

I have tried editing the 'script' config variable but it just throws an error on startup.

Any help?

switchToIFrame() for dynamic names

as discussed during facebook chat, switchToIFrame() does not use CSS/XPath selector to determine an Iframe for a switch if such iFrame have dynamic name

Can't run codeception on Windows 7

Setup codeception using Composer.

try run php vendor/bin/codecept , see

SRC_DIR="pwd"
cd "dirname "$0""
cd "../Codeception/Codeception"
BIN_TARGET="pwd/codecept"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

Codeigniter 2 and codeception

Hi
i have a clean CodeIgniter framework version 2 installed.
And created a phpunit test in /tests/unit/PostTest.php with following contents:

CI = &get_instance(); $this->CI->load->database('testing'); } public function testGetsAllPosts() { $this->CI->load->model('post'); $posts = $this->CI->post->getAll(); $this->assertEquals(1, count($posts)); } ``` } and this is my bootstrap: http://conversal.w0p.be/tests/unit/_bootstrap.phps when i run codecept run unit --bedug i get this: Running PostTest::testGetsAllPosts PHP Fatal error: Call to undefined function get_instance() in /var/www/sites/conversal.w0p.be/tests/unit/PostTest.php on line 9 PHP Stack trace: PHP 1. {main}() /usr/bin/codecept:0 PHP 2. Symfony\Component\Console\Application->run() /usr/bin/codecept:39 PHP 3. Symfony\Component\Console\Application->doRun() /usr/share/php/Codeception/vendor/Symfony/Component/Console/Application.php:105 PHP 4. Symfony\Component\Console\Command\Command->run() /usr/share/php/Codeception/vendor/Symfony/Component/Console/Application.php:188 PHP 5. Codeception\Command\Run->execute() /usr/share/php/Codeception/vendor/Symfony/Component/Console/Command/Command.php:227 PHP 6. Codeception\Codecept->runSuite() /usr/share/php/Codeception/src/Codeception/Command/Run.php:57 PHP 7. Codeception\SuiteManager->run() /usr/share/php/Codeception/src/Codeception/Codecept.php:89 PHP 8. Codeception\PHPUnit\Runner->doEnhancedRun() /usr/share/php/Codeception/src/Codeception/SuiteManager.php:130 PHP 9. PHPUnit_Framework_TestSuite->run() /usr/share/php/Codeception/src/Codeception/PHPUnit/Runner.php:97 PHP 10. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:705 PHP 11. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745 PHP 12. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772 PHP 13. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751 PHP 14. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:650 PHP 15. PostTest->setUp() /usr/share/php/PHPUnit/Framework/TestCase.php:801 FATAL ERROR OCCURRED. TESTS NOT FINISHED. it looks like it doens't load the _bootstrap?

seeLink with text only is always ok

In any of my acceptance tests if I do the following:
(suppose that response from /some/url doesn't contains "Not existent link" anywhere)

$I = new WebGuy($scenario);
$I->amOnPage('/some/url');

$I->seeLink('Not existent link');
$I->see('Not existent link');

The seeLink method returns OK but the see doesn't.
It's a bug or I'm missing something?

Thank you.

some mysql dumps can use '#' as comment symbol

Hi. Suggest some fix to PEAR\Codeception\src\Codeception\Util\Driver\Db.php
Line 88 replace with

if (preg_match('~^(--.*?)|(#)~s', $sql)) return true;

because some mysql dumps can use '#' as comment symbol. I am was liitle-little angry, while discover this theme ))

grabFromDatabase doesn’t work

Hey,

I’m new to Codeception but and I have a small problem. It might be me who doesn’t fully understand the framework, don’t bite me in that case please ;)

I have WebGuy test in which I wanted to get some data from database, just like this: $I->grabFromDatabase('users_data', array('phone' => '555666777'));.
I keep getting this error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

I thought it’s my mistake, but when I changed the grabFromDatabase to seeInDatabase it worked properly, so my syntax was apparently okay. It looks like Codeception is generating invalid SQL code, but it’s only my theory there’s a possibility that I’m wrong.

Cheers!

Bug in /src/Codeception/Step.php in getArguments() method

Привет.
Хотел заюзать метод seeResponseContainsJson в REST модуле, но столкнулся с багом. Условие задаю как в доке:

    $I = new ApiGuy($scenario);
    $I->wantTo('fail to create a new user by API');
    $params = [
        'email'       => '[email protected]',
        'password'    => 'qwertyui',
        'language_id' => '1'
    ];
    $I->sendPOST('/1/user/create', $params);
    $I->seeResponseIsJson();
    $I->seeResponseCodeIs(412);
    $I->seeResponseContainsJson(['error' => 'true']);
    $I->seeResponseContainsJson(['code' => 412]);

Но результат:

There was 1 error:                                                         

Couldn't fail to create a new user by api (QwertyCept.php)



  [ErrorException]                                                         
  8 Array to string conversion                                             

Длительная и глубокая отладка привела меня к:

    public function beforeStep(\Codeception\Event\Step $e) {
        $this->logger->info($e->getStep()->getHumanizedAction());
    }

в файле /pear/pear/Codeception/src/Codeception/Subscriber/Logger.php
а затем к getArguments в /pear/pear/Codeception/src/Codeception/Step.php

    /**
     * Returns this step's arguments.
     *
     * @param  boolean $asString
     * @return array|string
     */
    public function getArguments($asString = FALSE)
    {
        if (!$asString) {
            return $this->arguments;
        } else {
            $arguments = $this->arguments;

            foreach ($arguments as $k => $argument) {
                if (!is_string($argument) and is_callable($argument, true)) {
                    $arguments[$k] = 'lambda function';
                    continue;
                }
                if (is_object($argument)) {
                    if (method_exists($argument, '__toString')) {
                        $arguments[$k] = $argument->__toString();
                    } elseif (isset($argument->__mocked)) {
                        $arguments[$k] = $this->formatClassName($argument->__mocked);
                    } else {
                        $arguments[$k] = $this->formatClassName(get_class($argument));
                    }
                    continue;
                }
                // if (settype($argument, 'string') === false) throw new \InvalidArgumentException('Argument can\'t be converted to string or serialized');
            }

            switch (count($arguments)) {
                case 0:
                    return '';
                case 1:
                    return '"' . $arguments[0] . '"';
                default:

                    return stripcslashes(json_encode($arguments));

            }
        }
    }

Возможное решение (мне помогло) - такой код:

            switch (count($arguments)) {
                case 0:
                    return '';
                case 1:
                    if (is_array($arguments[0])) {
                        $arguments[0] = stripcslashes(json_encode($arguments[0]));
                    }
                    return '"' . $arguments[0] . '"';
                default:

Bug in printFail() in /src/Codeception/Subscriber/Console.php

D:\php.exe D:\www\Vendor\Codeception\codecept --debug run api PrimaryFlow_1Cept.php
Codeception PHP Testing Framework v1.1.1
Powered by PHPUnit 3.6.12 by Sebastian Bergmann.

Suite api started
ERROR

Time: 4 seconds, Memory: 6.25Mb

There was 1 error:
Couldn't test registration through api in PrimaryFlow_1Cept.php

Catchable fatal error: Argument 1 passed to Codeception\Subscriber\Console::printException() must be an instance of Exception, string given, called in D:\www\Vendor\Codeception\src\Codeception\Subscriber\Console.php on line 149 and defined in D:\www\Vendor\Codeception\src\Codeception\Subscriber\Console.php on line 187

Call Stack:
0.0004 132632 1. {main}() D:\www\Vendor\Codeception\codecept:0
0.4343 1098800 2. Symfony\Component\Console\Application->run() D:\www\Vendor\Codeception\codecept:40
0.4410 1294616 3. Symfony\Component\Console\Application->doRun() D:\www\Vendor\Codeception\vendor\Symfony\Component\Console\Application.php:105
0.4413 1295256 4. Symfony\Component\Console\Command\Command->run() D:\www\Vendor\Codeception\vendor\Symfony\Component\Console\Application.php:188
0.4419 1297600 5. Codeception\Command\Run->execute() D:\www\Vendor\Codeception\vendor\Symfony\Component\Console\Command\Command.php:227
3.8481 6118736 6. Codeception\Codecept->printResult() D:\www\Vendor\Codeception\src\Codeception\Command\Run.php:66
3.8481 6118832 7. PHPUnit_TextUI_ResultPrinter->printResult() D:\www\Vendor\Codeception\src\Codeception\Codecept.php:111
3.8481 6119184 8. PHPUnit_TextUI_ResultPrinter->printErrors() D:\server\pear\pear\PHPUnit\TextUI\ResultPrinter.php:156
3.8481 6119312 9. PHPUnit_TextUI_ResultPrinter->printDefects() D:\server\pear\pear\PHPUnit\TextUI\ResultPrinter.php:284
3.8482 6119608 10. Codeception\PHPUnit\ResultPrinter\UI->printDefect() D:\server\pear\pear\PHPUnit\TextUI\ResultPrinter.php:226
3.8482 6119944 11. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() D:\www\Vendor\Codeception\src\Codeception\PHPUnit\ResultPrinter\UI.php:20
3.8482 6120104 12. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() D:\www\Vendor\Codeception\vendor\Symfony\Component\EventDispatcher\EventDispatcher.php:53
3.8482 6120304 13. call_user_func() D:\www\Vendor\Codeception\vendor\Symfony\Component\EventDispatcher\EventDispatcher.php:162
3.8482 6120320 14. Codeception\Subscriber\Console->printFail() D:\www\Vendor\Codeception\vendor\Symfony\Component\EventDispatcher\EventDispatcher.php:162
3.8483 6121272 15. Codeception\Subscriber\Console->printException() D:\www\Vendor\Codeception\src\Codeception\Subscriber\Console.php:149

Process finished with exit code 255

Selenuim1

PHP Fatal error: Class '\Codeception\Module\Selenium1' not found in phar:///var/www/ch/codecept.phar/src/Codeception/Configuration.php on line 126

class_name: WebGuy
modules:
enabled:
- Selenium1
- WebHelper
config:
Selenium1:
url: 'http://site.ru'
browser: firefox

Invalid parameter type passed as Cookie

Have a clean CodeIgniter framework installed.
Created file tests/acceptance/StartPageCept.php with following content

wantToTest('front page of my site'); $I->amOnPage('/'); $I->see('Welcome to CodeIgniter'); Running **php codecept.phar run acceptance --debug** and have this stack trace Couldn't test front page of my site (StartPageCept.php) Exception thrown Zend\Http\Exception\InvalidArgumentException: Invalid parameter type passed as Cookie Stack trace: #1 addCookie C:\Program Files\Zend\ZendServer\bin\PEAR\mink\vendor\fabpot\goutte\src\Goutte\Client.php:95 #2 createClient C:\Program Files\Zend\ZendServer\bin\PEAR\mink\vendor\fabpot\goutte\src\Goutte\Client.php:60 #3 doRequest C:\Program Files\Zend\ZendServer\bin\PEAR\Symfony\Component\BrowserKit\Client.php:265 #4 request C:\Program Files\Zend\ZendServer\bin\PEAR\mink\src\Behat\Mink\Driver\GoutteDriver.php:111 #5 visit C:\Program Files\Zend\ZendServer\bin\PEAR\mink\src\Behat\Mink\Session.php:127 #6 visit phar://C:/workspace/ten/codecept.phar/src/Codeception/Util/Mink.php:27

Segmentation fault

Hi,
I'm trying to make working Codeception with an old Drupal 6 project. For now I'm focused on having Acceptance test working. So I created a new WebGuy scenario and made some assertions.

All is working fine but if I enable Db Module with a MySQL dump of 9 MB I get a "Segmentation fault" error.

With another little dump that creates only one table it works.

I can't understand.

Can you help me?

My dev machine is a Mac Book Pro with OSX 10.8.

Thank you.
Manuele Menozzi

bug-report.html bug

при генерации баг-репорта. если сайт не успевает прогрузиться - выскакивает сообщение не FAILURE а ERROR. в отчете увиличивается количество зафейленых тестов. но тест подкррашивается как прошедший.

Исправление:
(src/Codeception/PHPUnit/ResultPrinter/HTML.php)
/**
* Handler for 'on test' event.
*
* @param string $name
* @param boolean $success
* @param array $steps
*/
protected function onTest($name, $success = TRUE, array $steps = array(), $time = 0)
{
$this->timeTaken += $time;
if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
$scenarioStatus = 'scenarioFailed';
}

    else if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) {
        $scenarioStatus = 'scenarioSkipped';
    }

    else if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) {
        $scenarioStatus = 'scenarioIncomplete';
    }

    else if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR){
        $scenarioStatus = 'scenarioFailed';
    }

FillField Функциональные тесты

данный код
https://github.com/Codeception/Codeception/blob/master/src/Codeception/Util/Framework.php#L190

не работает с формой в которой есть кнопка вида,
<!!!!button class="float-right" type="submit">Войти, соотвественно не отрабатывается код

$form->children()->addHtmlContent(''); // for forms with no submits...
$form = $form->filter('input[type=submit]')->form();

почему то не добавляется к children() и соотвестенно пишет: "The current node list is empty.", потому что node $form->filter('input[type=submit]') не находится, пока не надумал как поправить

Если заменить код на такой, то тест начинает работать
$form = $form->filter('button[type=submit]')->form();
Страница которая тестируется http://pastebin.com/eufPcryv

$I = new TestGuy($scenario);
$I->wantTo('протестировать логин в админ панель');
$I->amOnPage('/admin/login');
$I->fillField('login','svsool');
$I->click('submit');
$I->see('Добро пожаловать');

Проблем с кодировкой

[2012-02-22 11:16:18] LoginCept.php.INFO: # FAILED # [] []
[2012-02-22 11:16:18] LoginCept.php.INFO: PASSED [] []
[2012-02-22 11:16:45] LoginCept.php.INFO: am on page "/admin/login" [] []
[2012-02-22 11:16:45] LoginCept.php.INFO: fill field ["login","svsool"] [] []
[2012-02-22 11:16:45] LoginCept.php.INFO: fill field ["pass","******"] [] []
[2012-02-22 11:16:45] LoginCept.php.INFO: click "submit" [] []
[2012-02-22 11:16:46] LoginCept.php.INFO: see "Вы вошли как: svsool (Администратор)" [] []
[2012-02-22 11:16:46] LoginCept.php.ALERT: ' Вы вошли как: svsool (Администратор)' in page..
Failed asserting that response contains "Вы вошли как: svsool (Администратор)". Response was saved to 'log' directory. [] []

В LoginCept.php.page.debug, данное сочетание есть, пробовал использовать хедеры в utf8, не помогло,
если пишу $I->see('Администратор'); не работает, пишу $I->see('svsool'); все работает.

Фреймворк Kohana он полностью на UTF8, и сайт на UTF8, с этим багом разберусь, напишу моудль для этого фреймворка.

кстати попробвал c селектором, тоже проблемы
Failed asserting that response contains "Администратор". Response was saved to 'log' directory. [] []
[2012-02-22 11:37:26] LoginCept.php.INFO: # FAILED # [] []
[2012-02-22 11:37:26] LoginCept.php.INFO: PASSED [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: am on page "/admin/login" [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: fill field ["login","svsool"] [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: fill field ["pass","********"] [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: click "submit" [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: see ["u0410u0434u043cu0438u043du0438u0441u0442u0440u0430u0442u043eu0440","li"] [] []
[2012-02-22 11:39:48] LoginCept.php.ALERT: 'li' selector.
Failed asserting that response contains "Администратор". Response was saved to 'log' directory. [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: # FAILED # [] []
[2012-02-22 11:39:48] LoginCept.php.INFO: PASSED [] []
AJAX на странице нету, а строка выглядит как AJAX

debug page из логов
http://pastebin.com/5bz7tDAT
сами логи
http://pastebin.com/MaWc1ejm

Make the phar file self executable

It would be good idea to make the phar file self executable with putting '#!/usr/bin/env php' to begining of the phar file
This way we could link it to PATH and use it trough system

UTF-8 bugs

Если передать в метод see() метку с национальными символами в utf-8, то всё работает правильно до момента пока вторым параметром не указать селектор области поиска.
Пример:

$I->see('Москва');

  • I see «Москва»
    OK

$I->see('Москва', 'div');

  1. I see ["\u041c\u043e\u0441\u043a\u0432\u0430",«div»]

FAILURES!

Кроме того, если на форме есть поля, заполненные кириллицей, то после сабмита и сохранения данных в базе данных наблюдаются крокозябры.
Оба бага были замечены в приемочных тестах. Возможно, присутствуют и в функциональных

Explain errors in Doctrine2

I think Codeception must tell readable errors, if table doesn't have record, because current error, not correct, for example:

public function insertAndGetRecord(CodeGuy $I)
{
    $I->expect('Object would be added in database, ParamGroup table.');

    $paramGroup = new $this->entityClass;

    $I->persistEntity($paramGroup, array('title' => 'Just title'));

    $I->seeInRepository('CatalogBundle:ParamGroup', array('title' => 'test'));
}

This test by steps return:

Running Codeception\TestCase\Cest::insertAndGetRecord
Scenario:

I expect Object would be added in database, ParamGroup table.
* I persist entity "CatalogBundle\Entity\ParamGroup",{"title":"Just title"}
* I see in repository "CatalogBundle:ParamGroup",{"title":"test"}
  ERROR

Time: 1 second, Memory: 32.50Mb

There was 1 error:

---------
1) Codeception\TestCase\Cest::insertAndGetRecord
ReflectionException: Property repositories does not exist

If i make correct test where both titles will be equal, all is ok.

And i don't get, how i should understand, what exactly i doing wrong by "ReflectionException"...

Error by using selenium

When I test acceptance test with Selenium I got some bug. Maybe it is related to Xpath element positionoing ? All other test with selenium runs just fine, just this one throws error.

  • Selenium 2.15.0 + Java 1.6.0.21
  • Codecept version 1.0.1
  • PHP 5.3.8 (32b)
  • Win7 64b

searchAjaxCept.php:

<?php
$I = new WebGuy($scenario);
$I->wantToTest("EHMK/searchAjax");
$I->amOnPage("/");

/*for Selenium*/ 
$I->fillField("html body.lang-sk div#wrapper.container_12 div#main.container_12 div#box_search form#search_form fieldset div#search_bg input[name=search-input]", "mus");
//now ajax fires and finds "music" and "museums"
//JS parses ajax output creates <ul><li><a>music</></li><li><a>museums</a></li></ul>
//now I simulate click on <a> in second <li>
//XPath
$I->click("/html/body/ul/li[2]/a");
$I->see("museums");
?>

D:\codecept run acceptance --debug

There was 1 error:

Couldn't test ehmk/searchajax (searchAjaxCept.php)
  Exception thrown Symfony\Component\CssSelector\Exception\ParseException:
  Unexpected symbol: / at 0
  Stack trace:
   #1 tokenizeSymbol D:\devel\apache\php\PEAR\Symfony\Component\CssSelector\Tokenizer.php:99
   #2 tokenize D:\devel\apache\php\PEAR\Symfony\Component\CssSelector\CssSelector.php:93
   #3 parse D:\devel\apache\php\PEAR\Symfony\Component\CssSelector\CssSelector.php:61
   #4 toXPath D:\devel\apache\php\PEAR\mink\src\Behat\Mink\Selector\CssSelector.php:27
   #5 translateToXPath D:\devel\apache\php\PEAR\mink\src\Behat\Mink\Selector\SelectorsHandler.php:94
   #6 selectorToXpath D:\devel\apache\php\PEAR\mink\src\Behat\Mink\Element\Element.php:67
   #7 findAll D:\devel\apache\php\PEAR\mink\src\Behat\Mink\Element\Element.php:57
   #8 find D:\devel\apache\php\PEAR\Codeception\src\Codeception\Util\Mink.php:127
   #9 findEl D:\devel\apache\php\PEAR\Codeception\src\Codeception\Util\Mink.php:109

I cannot use CSS selector unless some changes are made in web page source, so then I get:

There was 1 failure:

Couldn't test ehmk/searchajax (searchAjaxCept.php)
 Exception thrown PHPUnit_Framework_AssertionFailedError:
 Link or Button or CSS for 'html body.lang-sk ul.ui-autocomplete li.ui-menu-item a.ui-corner-all' not found'
 Stack trace:
   #1 fail D:\devel\apache\php\PEAR\Codeception\src\Codeception\Util\Mink.php:128
   #2 findEl D:\devel\apache\php\PEAR\Codeception\src\Codeception\Util\Mink.php:109

checkOption doesn't work with radio inputs

Example html

<div class="reg-form-checkbox">
        <label>
            <input type="radio" name="current_tax[tax_id]" id="current_tax_tax_id_1" value="1" > Tax single
        </label>
</div>
$i->checkOption('#current_tax_tax_id_1');

Throws error

Couldn't test select tax (StartPageCept.php)
  Exception thrown LogicException:
  You cannot tick "current_tax[tax_id]" as it is not a checkbox (radio).
  Stack trace:
   #1 tick /usr/share/php/mink/src/Behat/Mink/Driver/GoutteDriver.php:329
   #2 check /usr/share/php/mink/src/Behat/Mink/Element/NodeElement.php:147
   #3 check /usr/share/php/Codeception/src/Codeception/Util/Mink.php:213

Codeception PHP Testing Framework v1.0.7

Incomplete(?) Instructions Make Getting Started Difficult

After downloading codecept.phar, the installation instructions advise the user to try the following:

php codecept.phar
php codecept.phar bootstrap
php codecept.phar run

The run command, however, yields an Exception - appropriately advising the user that they first need to enter a valid URL in acceptance.suite.yml. Perhaps this should be an explicit step in the installation instructions, that could be added after bootstrapping?

Then, in the 'Getting Started' section of the docs, the user is told to try the following commands:

php codecept.phar build
php codecept.phar generate:cept Signin

The generate command, however, errors out with the following Exception:

  [RuntimeException]     
  Not enough arguments.  

generate:cept suite test

It seems to the user that the wrong number of arguments was used - perhaps we need to specify a 'suite' and a 'test', as suggested in the error message:

php codecept.phar generate:cept SigninSuite SigninTest

Trying this, however, yields the following error:

[Exception]                       
  Suite SigninSuite was not loaded  

generate:cept suite test

A bit confusing for new users. The user must be willing to dig through the code to find out how the different loaders and config files are stitched together, in order to proceed past this point...

Тестирование + база

Не как не могу понять, как сделать проверку в базе.
К примеру есть скрипт который тестирует регистрацию
$I->click('Регистрация');
$I->fillField('UserRegaEmail', '[email protected]');
$I->fillField('UserRegaRegion', '1');
$I->fillField('UserRegaPass', '123123');
$I->fillField('UserRegaName', 'testcept');
$I->click('#UserRega');

После него мне нужно проверить есть ли данные в базе, как мне это сделать ?
$I->seeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]'));

не будет работать, потому что $I = new WebGuy($scenario); нет такого метода

tests by group

How to run group of the tests from separate folder or using mask (Create*Cept.php, for example)?

Symfony 1.4 change app name?

Hi, how exactly i can change application name for Symfony 1.4? I see $app variable, but i don't get where change it.

P.S. May be add this into documentation.

Unit + Db + Selenuim

Вообщем то как запустить тесты по очереди.

  1. Я проверяю регистрацию с помощью selenuim
  2. Я проверю базу, есть ли мой пользователь
  3. Я проверяю все ли впордяке с помощью unit

как запустить все 3 теста поочереди ?

Runnig Codeception on Windows 7

Trying to run it on Windows 7, but there are problems with encoding. Running tests on Linux work fine.

Did you try to do this?

p.s. Test contain Cyrillic letters.

selenium2 switchToIframe&switchToWindow

на данный момент официально есть возможности работать с iframe и переключаться по окнам в процессе выполнения теста

html report generation fails

if i run codeception with:

codecept run --debug --html

it return this error message:
[ErrorException]
fwrite(): 125 is not a valid stream resource

How to generate a html reports ? For example for jenkins.

My Platform is Ubuntu 11.10 and all deps are clean installed.

Thx :)

Apostrophe escaping breaks Selenium "see" matching

I've set up automated testing using Selenium and codeception, but unfortunately some of the tests fail due to the "see" action on selenium excepting apostrophes (and likely other characters).

_404Cept.php_

<?php
$I = new WebGuy($scenario);
$I->wantTo('See a friendly 404 error message for wrong url');
$I->amOnPage('/blahblahblah');
$I->see("The page you requested couldn't be found!",'h1');

Suite acceptance started
Trying to see a friendly 404 error message for wrong url (404Cept.php) - Failed

Suite functional started

Time: 7 seconds, Memory: 12.75Mb

There was 1 failure:

Couldn't see a friendly 404 error message for wrong url (404Cept.php)
Guy couldn't see ["The page you requested couldn't be found!","h1"] 'h1' selector For more details look for page snapshot in the log directory
Failed asserting that 'SEERveyThe page you requested couldn't be found!' contains _"The page you requested couldn't be found!"_.

  1. I see ["The page you requested couldn't be found!","h1"]
  2. I am on page "/blahblahblah"
  3. I want to See a friendly 404 error message for wrong url

FAILURES!
Tests: 1, Assertions: 0, Failures: 1.

However, if I remove the apostrophe (and any content after it) the test correctly identifies the content:

_404Cept.php_

<?php
$I = new WebGuy($scenario);
$I->wantTo('See a friendly 404 error message for wrong url');
$I->amOnPage('/blahblahblah');
$I->see("The page you requested couldn",'h1');

Suite unit started

Suite acceptance started
Trying to see a friendly 404 error message for wrong url (404Cept.php) - Ok

Suite functional started

Time: 8 seconds, Memory: 12.50Mb

OK (1 test, 0 assertions)

Error when calling REST::seeResponseContainsJson()

I'm getting this error every time I call:

$I->seeResponseContainsJson(array("result" => "success"));
ErrorException: 4096 Argument 2 passed to Codeception\Module\REST::arrayHasArray() must be an array, null given, called in phar:///Users/jordan/Web/fergus/codecept.phar/src/Codeception/Module/REST.php on line 210 and defined

Any ideas?

Selenium2 select

$I->fillField('UserRegaRegion', '1');

WebDriver\Exception\UnknownError: Element must be user-editable in order to clear it.
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-32-generic', java.version: '1.6.0_24'
Driver info: driver.version: unknown

Fatal Error when testing form.

I am new to codeception so I apologize if I have any misunderstanding with the usage.
I got the following error when I try to run a form I made.

$I->submitForm('#apply-online', array(
    'apply_name' => 'foobar',
    'apply_tel' => '800-123-1111',
    'apply_email' => '[email protected]',
    'apply_msg' => 'A Test',
    'agree' => 'on',
));

Fatal error: Call to undefined method Symfony\Component\DomCrawler\Field\InputFormField::addChoice() in phar:///Applications/MAMP/htdocs/myform/codecept.phar/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php on line 374 FATAL ERROR OCCURRED. TESTS NOT FINISHED.


In addition to that
I tried to following what the site said @ http://codeception.com/docs/04-AcceptanceTests
I got errors when I use $I->press('Update'); following in the example. But I got problem with $I->click('Update');

This is from the example.

$I = new WebGuy($scenario);
$I->amOnPage('testform.html');
$I->fillField('Name', 'Miles');
// we can use input name, or id
$I->fillField('user[email]','[email protected]');
$I->selectOption('Gender','Male');
$I->press('Update');

Include Phar-stub including shebang

Compare with composer :) It's about to call the downloaded phar directly on linux-system

here is should be

#!/usr/bin/env php
<?php
Phar::mapPhar('codeception.phar');
require 'phar://codeception.phar/codecept';

Composer Installation Yields Unusable Project

SUMMARY
When doing an installation of Codeception via Composer, the codecept script ends up being unusable because of a bad directory reference in Codeption's autoload.php file.

The file:
'[...]/vendor/Codeception/Codeception/autoload.php'
probably intends to load:
'[...]/vendor/composer/autoload_namespaces.php'
but instead it ends up asking to load:
'[...]/vendor/Codeception/Codeception/vendor/composer/autoload_namespaces.php'
which doesn't exist.

This renders the installation via Composer unusable. :-(

STEPS TO REPRODUCE
In a brand new directory, create a new composer.json file, as described in the installation instructions of the manual:

{
    "require": {
        "codeception/codeception":  "1.*@dev"
    },
    "minimum-stability": "dev"
}

Then, using your Terminal, cd into your new directory, and install Codeception via Composer:

composer install

If everything goes well, after a few minutes you should have your 'vendor' sub-directory, and also the Composer 'autoload.php' file in your project directory.

According to the installation instructions, you should now be able to run the 'codecept' command, found inside the 'vendor/bin' directory, like this:

php vendor/bin/codecept

Doing that, however, yields the following error:

Warning: require_once(/path/to/project/vendor/Codeception/Codeception/
vendor/composer/autoload_namespaces.php): failed to open stream: No such file 
or directory in /path/to/project/vendor/Codeception/Codeception/autoload.php 
on line 5

Fatal error: require_once(): Failed opening required '/path/to/project/vendor/
Codeception/Codeception/vendor/composer/autoload_namespaces.php' (include_path='.:') 
in /path/to/project/vendor/Codeception/Codeception/autoload.php on line 5

The user is not able to execute the codecept script.

Constraint\Page::failureDescription() has wrong declaration

Trying to run a basic test from the http://codeception.com I get the following exception:


Declaration of Codeception\PHPUnit\Constraint\Page::failureDescription() 
should be compatible with that of PHPUnit_Framework_Constraint::failureDescription()

I checked both sources and had found the difference:


#Codeception\PHPUnit\Constraint\Page::failureDescription() 
protected function failureDescription($other){...}

#PHPUnit_Framework_Constraint::failureDescription()
protected function failureDescription($other, $description, $not){...}

Does this bug come from differences in versions?

Selenium 'click' too restrictive

Hi,
in modern day web development (especially what I am using codeception for) I find only allowing 'click' to work on links and buttons a major issue. Would there be any disadvantage in replacing $el = $this->findClickable($link) with $el = $this->findEl($link)?
This would allow clicking of li or div tags that have some kind of JS attached to them.
Thank you for your help,
Mark.

syntax error in postgesql query

PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "`"
LINE 1: select count(*) from `users` where `email` = $1

tablename and fields work with wrapped by double quotes or without
values with single quotes

work

select count(*) from users where email = '[email protected]';
select count(*) from "users" where email = '[email protected]';

don't work

select count(*) from `users` where email = '[email protected]';
select count(*) from users where email = "[email protected]";

psql (PostgreSQL) 9.2.1

Selenium2

RuntimeException: Call to undefined method WebGuy::cancelPopup

acceptance.suite.yml
class_name: WebGuy
modules:
enabled:
- Selenium2
- WebHelper
config:
Selenium2:
url: 'http://local.loc'
browser: chrome
delay: 350

./vendor/bin/codecept build: Configuration file is invalid

composer.json:

{
    "require": {
        "Codeception/Codeception": "dev-master"
    },
    "minimum-stability": "dev"
}

After update I want to build a new Codeception project:

$ ./vendor/bin/codecept build

But in result I got this exception:

[Codeception\Exception\Configuration]
Configuration file is invalid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.