Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi! I’ve installed

U016ZN12N4A
U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

Hi!

I’ve installed spryker-b2b-demo in docker & dev mode.

I tried to get Tests running by using the bootcamp StringReverser example.

Running the tests in docker with docker/sdk testing codecept run -c tests/PyzTest/Zed/StringReverser results in:

PyzTest\Zed\StringReverser.Business Tests (1)  

E StringReverserFacadeTest: String is reversed correctly 
E StringReverserFacadeTest: String is reversed correctly (0.00s)

In ConnectionFactory.php line 43:

  Unable to open connection  


In PdoAdapter.php line 72:

  Unable to open PDO connection  


In PdoConnection.php line 59:

  SQLSTATE[08006] [7] could not connect to server: Connection refused  
        Is the server running on host "127.0.0.1" and accepting             
        TCP/IP connections on port 5432?      

This is not the desired Exception, in the bootcamp the exception was FacadeNotFoundException. And I don’t think there should be a PDOException since there is no DB involved (or is it, the test runs in the Business Layer 🤔)?

Running docker desktop 2.3.0.3 (stable) on macOS Catalina v 10.15.5 with recommended docker settings.

Can you help me or point me in a direction to get the tests working in docker? 🤗

Comments

  • anyway, first guess: the codeception.yml from our example loads too many unnecessary modules

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet

    Please, try different way to run tests:

    docker/sdk testing codecept run -g StringReverser

    To speed up the run you can change codeception.yml or create your own and set include: to include only necessary test.

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    @UJN2JRU4F codeception.yml

    namespace: PyzTest\Zed\StringReverser
    
    paths:
        tests: .
        data: _data
        support: _support
        log: _output
    
    coverage:
        enabled: true
        remote: false
        whitelist: { include: ['../../../../src/*'] }
    
    suites:
        Business:
            path: Business
            class_name: StringReverserBusinessTester
            modules:
                enabled:
                    - Asserts
                    - \PyzTest\Shared\Testify\Helper\Environment
                    - \SprykerTest\Shared\Testify\Helper\ConfigHelper
                    - \SprykerTest\Shared\Testify\Helper\DependencyHelper
                    - \SprykerTest\Shared\Propel\Helper\TransactionHelper
                    - \SprykerTest\Shared\Testify\Helper\LocatorHelper:
                          projectNamespaces: ['Pyz']
    

    1:1 from the bootcamp

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    @ULYHPR789 the command does not run any test with my current configuration. But I’ll investigate - thx for the hint. I’ll come back at you with new results 😄

  • another first guess (looks like my first guesses are not very good today 😊)

  • @ULYHPR789’s command calls a specific group

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    mondays.. 😄 ¯_(ツ)_/¯

  • the group does not exists on the test

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    i thought so, currently checking codeceptions documentation on how to fix it

  • oh, it does

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    is it the namespace attribute, that defines the group?

  • no there is a @group annotation on top of the test class

  • Unknown
    edited July 2020

    (there are actually a lot of those)

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    ahh thx for pointing that out

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet
    [PyzTest\Zed\StringReverser]: tests from /data/tests/PyzTest/Zed/StringReverser
    
    
    PyzTest\Zed\StringReverser.Business Tests (0) 
    
  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    i am such an idiot…

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    i ran the codeceptionwith the complete namespace not the group StringReverser🤦‍♂️

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet
  • Unknown
    edited July 2020

    i will add the docker specific stuff to the bootcamp in the next iteration. thanks for pointing it out! 👍

  • main thing is that it works now 😉

  • U016ZN12N4A
    U016ZN12N4A Posts: 20 🧑🏻‍🚀 - Cadet

    yea it works - thanks again

  • U01C0GDQFEC
    U01C0GDQFEC Posts: 12 🧑🏻‍🚀 - Cadet

    What was the solution for this? I have the exact same problem (also using docker). All the"@group" tags within my test class are out-commented.

  • U01D7EW4N73
    U01D7EW4N73 Posts: 9 🧑🏻‍🚀 - Cadet
    edited October 2020

    For me removing the \SprykerTest\Shared\Propel\Helper\TransactionHelper from codeception.yml was enough (run codecept build -c tests/PyzTest/Zed/StringReverser afterwards) – neither test nor module use persistence so it shouldn't be required. Main issue seems to be that the docker.dev environment which the testing container uses sets up the database connection by including common/config_services-devvm.php where the DB host is set to localhost (which seems wrong to me at first glance).

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet

    It APPLICATION_ENV=devtest instead of docker specific one.

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet

    This file https://github.com/spryker-shop/b2b-demo-shop/blob/master/tests/PyzTest/Shared/Testify/_support/Helper/Environment.php should be like this:

    <?php
    
    /**
     * This file is part of the Spryker Suite.
     * For full license information, please view the LICENSE file that was distributed with this source code.
     */
    
    namespace PyzTest\Shared\Testify\Helper;
    
    use Codeception\Module;
    use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfig;
    use Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface;
    
    class Environment extends Module
    {
        protected const TESTING_APPLICATION_ENV_NAME = 'devtest';
    
        /**
         * @return void
         */
        public function _initialize()
        {
            $rootDir = realpath(__DIR__ . '/../../../../../../');
            $applicationEnv = $this->getApplicationEnv();
    
            defined('APPLICATION_ENV') || define('APPLICATION_ENV', $applicationEnv);
            defined('APPLICATION_STORE') || define('APPLICATION_STORE', (isset($_SERVER['APPLICATION_STORE'])) ? $_SERVER['APPLICATION_STORE'] : 'DE');
            putenv('APPLICATION_STORE=' . APPLICATION_STORE);
    
            defined('APPLICATION') || define('APPLICATION', '');
    
            defined('APPLICATION_ROOT_DIR') || define('APPLICATION_ROOT_DIR', $rootDir);
            defined('APPLICATION_SOURCE_DIR') || define('APPLICATION_SOURCE_DIR', APPLICATION_ROOT_DIR . '/src');
            defined('APPLICATION_VENDOR_DIR') || define('APPLICATION_VENDOR_DIR', APPLICATION_ROOT_DIR . '/vendor');
    
            defined('APPLICATION_CODE_BUCKET') || define('APPLICATION_CODE_BUCKET', $this->createCodeBucketConfig()->getCurrentCodeBucket());
            putenv('APPLICATION_CODE_BUCKET=' . APPLICATION_CODE_BUCKET);
        }
    
        /**
         * @return string
         */
        protected function getApplicationEnv(): string
        {
            if (getenv('SPRYKER_TESTING_ENABLED')) {
                return getenv('APPLICATION_ENV');
            }
    
            return static::TESTING_APPLICATION_ENV_NAME;
        }
    
        /**
         * @return \Spryker\Shared\Kernel\CodeBucket\Config\CodeBucketConfigInterface
         */
        protected function createCodeBucketConfig(): CodeBucketConfigInterface
        {
            return new CodeBucketConfig();
        }
    }