Search code examples
phptestingcodeceptionacceptance-testing

Codeception - Different Results in Different Envionments


I'm using Codeception to run some acceptance tests on a codebase. I have a pretty straight forward configuration for my tests:

class_name: WebGuy
modules:
    enabled: [PhpBrowser, WebHelper, Db]

When I run these locally in MAMP on OSX, all the tests function properly.

I've now created a staging server on Rackspace that's running CentOS. Upon running the same test suite, I run into a handful of errors that mostly have to do with running $I->click('something'). In the cases where it fails, the item to be clicked is a somewhat generic <a> tag, and has no classes or ID. As such, I had been referring to it by it's text:

<a href='http://google.com'>google</a>
$I->click('google');

This seems to work fine locally, however, is now failing on staging.

I'm wondering what factors might contribute to this difference? Staging runs the same version of PHP that I am. However, I do notice that slightly different versions of CURL are running.


Solution

  • Chalking this one up to user error: In Codception, when a test fails at a particular assertion, it's important to remember that ANYTHING associated with that step could cause an issue, not only the explicit aspect being tested.

    In my case, if a test fails to assert that a certain row is present in the database after an insert query, it could have failed because there was a file upload component and permissions for that directory were not open enough.