Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog


Articles on this Page

(showing articles 221 to 222 of 222)
(showing articles 221 to 222 of 222)

Channel Description:

Codeception: BDD-style testing in PHP

older | 1 | .... | 10 | 11 | (Page 12)

    0 0
  • 02/26/18--17:03: Codeception 2.4 released
  • Hello everyone! We’d like to announce the immediate availability of Codeception 2.4.0. This follows up the PHPUnit 7.0 release and mostly contains compatibility fixes for latest PHPUnit. Internal usage of PHPUnit in Codeception was switched to new namespaced class names. This doesn’t break any public APIs but can break some setups. That’s why this is a minor release with a proper announcement. Please upgrade and unless you have some PHPUnit version conflict you should not experience any issues.

    Codeception 2.4.0 is a stability release. We also dropped unmaintained PHP 5.4 and PHP 5.5. But we keep compatibility with PHP 5.6 so if your company still uses PHP 5 (and we understand business reasons) you can install this update too. Codeception is still going to be maintained with PHP 5.6 compatibility in mind. We don’t break API just for the sake of clean code. We try to make things reliable.

    In the same Codeception 2.3.9 is released time so if you want to get the latest changes and you still use old PHP, upgrade to this version.

    In Codeception 2.4 you will also find new hooks for Cest files:

    • _passed is called when a test inside Cest is successful
    • _failed is called for unsuccessful tests
    • _after is called at the end of a test for both cases.

    Previously _after hook worked as _passed and that behavior was confusing. This was changed so it can be potentially a breaking change as well.

    See changelog for the complete list of fixes and improvements.


    We also launched Codeception Slack to talk about testing and Codeception.

    Join Slack

    We’d also love to see more contributors there. We need more talented developers to help to bring new features and fix the issues. It’s opensource, after all. We face constant challenges: new APIs, new libraries, new approaches, etc. And Codeception as a really big project would benefit from any help. We are open to accepting new maintainers, to discuss trends, to build a better product! As you know, we are merging 90% of submitted Pull Requests so if you are not contributing, please go ahead!


    We try to keep Codeception going and bring more releases to you. If your company uses this framework and you’d like to give back please consider sponsoring Codeception. That’s right. We are asking to invest into open source, to get the features you expect and to give back to open source.

    Sponsor Codeception

    Please show this form to your company bosses. If you want to have stable reliable product it’s ok to pay for that. Be our first official sponsors!

    Yes, we also provide enterprise support and trainings. This is another way you can support the development. Thank you!


    0 0
  • 09/23/18--18:03: Codeception 2.5: Snapshots
  • The Autumn is a good time to start something new. How about new Codeception? As you know, each minor release indicates some important change, new features we wanted to share. This time we want to introduce you to

    Snapshots

    That’s the new feature, which might be useful if you are tired of harcoding your data into fixtures. For instance, when you test the search engine you don’t know the exact list of items to check, however, you are interested that the list would be the same every time for a search term. What about API responses? You don’t want to hardcode it fully but you may want to check that response is the same as it was before.

    So now Codeception can do what php-vcr was doing all the time. Saving data into the file (called snapshot), and comparing with it on next runs.

    This is nice feature for testing REST APIs.

    Let’s assume you have such JSON response.

    {
      "firstName": "John",
      "lastName" : "doe",
      "phoneNumbers": [
        {
          "type"  : "iPhone",
          "number": "0123-4567-8888"
        },
        {
          "type"  : "home",
          "number": "0123-4567-8910"
        }
      ]
    }
    

    And you want to check that phone numbers are the same on each run. For this we can use a snapshot.

    namespace Snapshot;
    
    class PhoneNumberSnapshot extends Codeception\Snapshot {
      
        /** @var \ApiTester */
        protected $i;
    
        public function __construct(\ApiTester $I)
        {
            $this->i = $I;
        }
    
        protected function fetchData()
        {
            // return an array of phone numbers
            return $this->i->grabDataFromResponseByJsonPath('$.phoneNumbers[*].number');
        }  
    
    }
    

    Then in test we can check if data matches the snapshot by calling the snapshot class:

    public function testUsers(ApiTester $I, \Snapshot\PhoneNumberSnapshot $shapsnot)
    {  
      $I->sendGET('/api/users');
      $snapshot->assert();
    }
    

    If the data changes, snapshot is easy to update. Just run the test in --debug mode. The snapshot will be overwritten with a new data.

    So, the good thing about snapshots:

    • you don’t keep flaky data in your code
    • you don’t need to hardcode data values
    • data can be easily updated on change

    Use them!


    There are also some other minor changes:

    • Db module now supports multiple database connections. If you use few databases we got you covered! That was a long awaited feature and finally we have a very nice implementation from @eXorus.
    • --seed parameter added to run so you could rerun the tests in same order. This feature works only if you enabled shuffle mode.
    • Possible breaking: seeLink behavior changed.
      • Previous: $I->seeLink('Delete','/post/1'); matches <a href="/post/199">Delete</a>
      • Now: $I->seeLink('Delete','/post/1'); does NOT match <a href="/post/199">Delete</a>

    See changelog for the complete list of fixes and improvements.

    Thanks to all our contributors who made this release happen!


    Call to Sponsors!

    We try to keep Codeception going and bring more releases to you. If your company uses this framework and you’d like to give back please consider sponsoring Codeception. That’s right. We are asking to invest into open source, to get the features you expect and to give back to open source.

    For instance, how would you like improving stability of WebDriver tests? It would be cool to automatically retry failed steps and rerun failed tests. These could be a very cool features but they can’t be made without your help.

    If you are interested consider sponsoring us:

    Sponsor Codeception

    Yes, we also provide enterprise support and trainings. This is another way you can support the development. Thank you!


older | 1 | .... | 10 | 11 | (Page 12)