2
votes

I'm running the latest version of Codeception on a vagrant box and I can't get either the acceptance or functional testing working.

Here's acceptance.suite.yml:

class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser
        - AcceptanceHelper
    config:
        PhpBrowser:
            url: 'http://test.dev'

and my acceptance test:

$I = new AcceptanceTester($scenario);
$I->wantTo('check Codeception');

$I->amOnPage('/');

$I->see('hello');

The index page is a simple html output with 'hello world'

The error I'm getting is as follows:

1) Failed to check codeception in testTestCept (/vagrant/test/tests/acceptance/testTestCept.php)
Sorry, I couldn't am on page "http://test.dev/":
GuzzleHttp\Exception\RequestException: cURL error 6: Couldn't resolve host 'test.dev'

Scenario Steps:
1. I am on page "http://test.dev/"

#1  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4  /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5  /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6  /vagrant/fmx/tests/acceptance/testTestCept.php:5
#1  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4  /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5  /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6  /vagrant/fmx/tests/acceptance/testTestCept.php:5

My functional test is just as simple:

$I = new FunctionalTester($scenario);
$I->wantTo('check Codeception');

$I->amOnPage('/');

$I->see('hello');

With this one I get the following error:

There was 1 error:

---------
1) Failed to check codeception in testTestCept (/vagrant/test/tests/functional/testTestCept.php)
#1  /vagrant/test/tests/functional/testTestCept.php:5
#2  /vagrant/test/tests/functional/testTestCept.php:5

Line 5 is specifically: $I->amOnPage('/');

I'm new to vagrant so I'm not sure if I've missed something in the setup or if I've done something else wrong. I'm running codeception through vagrant ssh.

UPDATE:

We've got the Acceptance testing working. Now just focusing on the Functional testing. As requested, below is the complete functional.suite.yml content. As I'm setting up in stages, I've not actually modified this:

# Codeception Test Suite Configuration

# suite for functional (integration) tests.
# emulate web requests and make application process them.
# Include one of framework modules (Symfony2, Yii2, Laravel4) to use it.

class_name: FunctionalTester
modules:
    enabled: [Filesystem, FunctionalHelper]
1
I think amOnPage() method cannot accept full url. Try amOnPage('/') for your acceptance test (functional is another case so there is another problem). - Phantom
Sorry Phantom: I did actually try it both ways I missed the edit on the output to show it correctly I used amOnPage('/') and it still didn't work. - TH1981
Try url: 'http://test.dev:80' - Laurence
tried that @The Shift Exchange and it didn't work. same result :/ - TH1981
because you are running codeception within vagrant - perhaps it needs to be "localhost" or "192.168.0.1" or something like that. check your settings within vagrant for the website address - Laurence

1 Answers

2
votes

I had the same problem and this helped me:

unable to run codeception in virtual machine -Mink could not be found and loaded

I needed to add an entry in my /etc/hosts file for my site inside of my vm.