Code Monkey home page Code Monkey logo

codeception.github.com'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.github.com's People

Contributors

alexkuc avatar annechko avatar arhell avatar arzzen avatar captbaritone avatar cjaoude avatar davertmik avatar dependabot[bot] avatar edno avatar exorus avatar fkupper avatar gimler avatar githubeing avatar imme-emosol avatar javigomez avatar jonathanbossenger avatar lucatume avatar mcustiel avatar mendicm avatar naktibalda avatar nathanmac avatar pablopaul avatar paulohenriquesg avatar phpcodemonkey avatar polevaultweb avatar ruudboon avatar samdark avatar tavoniievez avatar thomaslandauer avatar webmaster777 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeception.github.com's Issues

Codeception for yii: Redefine $mailer and other tips. New chapter?

https://github.com/Codeception/codeception.github.com/blob/master/for/yii.md

is so small guide

So... I want to redefine $mailer in functional tests. I find deprecated repo with info pages
https://github.com/yiisoft/yii2-codeception/blob/master/docs/guide/usage-reconfiguring-components-for-testing.md

But this is not representation in for/yii.md

How about expand for/yii.md or try any other way to write guide? New chapter?

Additional I wish add info about redefine $mailer in functional yii2 codeception tests:

You shouldn't define the _beforeSuite inside your Cest classes. Instead, you should use the Helper class inside _support.

in Helper

    /**
     * Set \Codeception\Module\Yii2::$mailer to \Yii::$app->mailer from test
     * For example
     * public function _before(FunctionalTester $I)
     * {
     *     \Yii::$app->set('mailer', \frontend\fixtures\MockMailer::class);
     *     $I->configureMailer();
     *     $I->amOnPage(['site/contact']);
     * }
     */
    public function configureMailer()
    {
        /** @var \Codeception\Module\Yii2 $module */
        $module = $this->getModule('Yii2');
        /** @var \yii\base\Application $app */
        $app = $module->app;
        /** @var \Codeception\Lib\Connector\Yii2 $connector */
        $connector = $module->client;
        $connector::$mailer = $app->get('mailer');
    }

rebuild Actors;
in cest use it

class ContactFailCest
{
    public function _before(FunctionalTester $I)
    {
        \Yii::$app->set('mailer', \frontend\fixtures\MockMailer::class);
        $I->configureMailer();
        $I->amOnPage(['site/contact']);
    }

    public function checkContactSubmitCorrectDataSendFail(FunctionalTester $I)
    {
        $I->submitForm('#contact-form', [
            'ContactForm[name]' => 'tester',
            'ContactForm[email]' => '[email protected]',
            'ContactForm[subject]' => 'test subject',
            'ContactForm[body]' => 'test content',
            'ContactForm[verifyCode]' => 'testme',
        ]);
        $I->dontSeeEmailIsSent();
        $I->see(Yii::t('main', 'There was an error sending your message.'));
    }
}

redefine class

namespace frontend\fixtures;


class MockMailer extends \Codeception\Lib\Connector\Yii2\TestMailer
{
    protected function sendMessage($message)
    {
        return false;
    }
}

Low contrast in mobile view

if you go to codeception.com with a narrow window (phone view) you will see that the contrast for the menu is not acessible:

capture 2016-06-01 at 15 36 16

Problems due to Mink Module

My script is returning errors due to Mink Module not working properly. When I try to configure Mink on my Mac I get this : Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your php.ini:
detect_unicode = Off

A php.ini file does not exist. You will have to create one.

The defined install dir (bin) does not exist.

Please help.

Codeception. Getting started. Need help.

Hi,
I am new to Codeception and am still trying to understand it. Though the code seems easy to grab, I am facing issues in getting simple scripts running. I need to test a website and only have its URL. I have specified the URL in the acceptance.yml config file. Whenever, I run my script I get the error : [Symfony\Component\Yaml\Exception\ParseException]
Indentation problem in cceptance.suite.yml" at line 16 (near " config:"). This is followed by Guy couldn't click: Link | button | CSS | XPath not found'. I understand, it is a configuration issue but am not able to fix it. Any help will be appreciated. Thanks.

DNS gone missing

The DNS for codeception.com seems to have gone missing. I guess there's probably meant to be an A or CNAME there or something. In any case, the site won't load. codeception.github.com redirects to codeception.com, too, so there's really no convenient way to access the documentation at the moment. Would be wonderful if this could be fixed up, even if just turning off the redirection and we have to use codeception.github.com for a while until the DNS can be fixed up for codeception.com.

Send headers

Hello,

So I need to send headers to my app but neither of these won't work:

class_name: ApiTester
modules:
    enabled:
        - Helper\Api
        - Asserts
        - REST:
            depends: Laravel5
            headers:
                header_1: value_1
        - Laravel5:
            environment_file: .env.dev
            cleanup: false # This removes the transaction error when running
            url: http://localhost
            # run_database_migrations: true
            # run_database_seeder: true
            # database_seeder_class: 'DatabaseSeeder'
class_name: ApiTester
modules:
    enabled:
        - Helper\Api
        - Asserts
        - REST:
            depends: Laravel5
        - Laravel5:
            depends: PhpBrowser
            environment_file: .env.dev
            cleanup: false # This removes the transaction error when running
            url: http://localhost
            # run_database_migrations: true
            # run_database_seeder: true
            # database_seeder_class: 'DatabaseSeeder'
        - PhpBrowser:
            url: http://localhost
            headers:
                header1: value_1

and Laravel5 does not appear to have a header option

Thanks,

Domain expired?

I tried to look up the documentations today, only to find that I cannot access the website. Doing a whois revealed that the domain have expired as of 27 Dec 2013 13:08:50:000 UTC. Is this a known issue, and if not, can someone on the team please see about renewing it?

broken indent

i could easily fix this myself and send a pull request but i think the indents are broken for a reason and a single manual fix won't help here. maybe your automatic code formatting tool isn't properly set up or you need to format this php code as some kind of a string literal or something... - donno. but the error is there.


(notice indents of lines 106-115)

Problems due to Mink Module

My script is returning errors due to Mink Module not working properly. When I try to configure Mink on my Mac I get this : Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your php.ini:
detect_unicode = Off

A php.ini file does not exist. You will have to create one.

The defined install dir (bin) does not exist.

Please help.

Implement a search function for the full docs

The search function in the docs (in the left bar, above the in-page table of contents) is basically useless, since it only duplicates what any browser offers with Ctrl+F.

What really would be useful, is a search function which searches the entire docs, especially across modules. Reason: In the users' minds, those modules are not separated, but all parts of the same thing (i.e. Codeception). This would allow users to discover functions which are "hidden" in modules they don't have or don't know of.

Font(Shanti) issue on Windows

On windows browsers font is displayed incorrectly. Tested on latest Chrome and Firefox browser. Windows 10 x64

image

After turn off Shanti font
image

Broken link

At the very bottom of this page [http://codeception.com/11-12-2013/working-with-phpunit-and-selenium-webdriver.html] the link much simpler manner using the WebGuy APIs leads to this address [(http://codeception.com/docs/04-AcceptanceTests)] and it doesn't work.

Add composer.json instructions in installation page

I'm missing in this page: http://codeception.com/install the description about how to install via composer with the json file. For example:

You can install Codeception via composer.

First create a composer.json in the root of your project with the following content:

{
    "require-dev": {
        "codeception/codeception": "*"
    }
}

Next, install composer in your system: https://getcomposer.org/doc/01-basic-usage.md#installation

And finally execute composer install using any of the following commands (depending on the way you installed composer):

php composer.phar install

or

composer install

How to get this going locally

Not exactly sure how to get this site working locally for development. I'm not seeing typical php, etc boot files. Haven't used much of static site generators, so maybe it's just that.

A quick README or CONTRIBUTING explaining this would be great.

Tnx

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.