Skip to content

@depends Dependencies across classes cannot properly check signature #5574

@joecot

Description

@joecot

What are you trying to achieve?

Trying to use the @Depends annotation to cause X test to run before Y test.
Attempting to do so in 4 different formats (based on console output differences)

  • try 1: @depends Core\CheckNewsTest:testAddNewsSection
  • try 2: @depends Core\CheckNewsTest::testAddNewsSection
  • try 3: @depends CheckNewsTest:testAddNewsSection
  • try 4: @depends CheckNewsTest::testAddNewsSection

What do you get instead?

  • try 1: Add news section is run before test but test is skipped with output:
    This test depends on "Core\CheckAffiliateTest::Core\CheckNewsTest:testAddNewsSection" which does not exist.
  • try 2: Add news section is not run before test and test is skipped with output:
    This test depends on "Core\CheckNewsTest::testAddNewsSection" to pass.
  • try 3: Add news section is not run before test and test is skipped with output:
    This test depends on "Core\CheckAffiliateTest::CheckNewsTest:testAddNewsSection" which does not exist.
  • try 4: Add news section is not run before test and test is skipped with output:
    This test depends on "CheckNewsTest::testAddNewsSection" which does not exist.

Provide console output if related. Use -vvv mode for more details.

  • try 1:
CheckAffiliateTest: Check affiliate news sections
 Test  tests/unit/Api/CheckAffiliateTest.php:testCheckAffiliateNewsSections
                                                                                                                                           
  [PHPUnit\Framework\Warning] This test depends on "Core\CheckAffiliateTest::Core\CheckNewsTest:testAddNewsSection" which does not exist.  
                                                                                                                                           
vendor/phpunit/phpunit/src/Framework/TestCase.php:1973
vendor/phpunit/phpunit/src/Framework/TestCase.php:1886
vendor/phpunit/phpunit/src/Framework/TestCase.php:706
vendor/phpunit/phpunit/src/Framework/TestSuite.php:568
vendor/codeception/phpunit-wrapper/src/Runner.php:117
vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
vendor/codeception/codeception/src/Codeception/Codecept.php:193
vendor/codeception/codeception/src/Codeception/Codecept.php:160
vendor/codeception/codeception/src/Codeception/Command/Run.php:385
vendor/symfony/console/Command/Command.php:255
vendor/symfony/console/Application.php:921
vendor/symfony/console/Application.php:273
vendor/symfony/console/Application.php:149
vendor/codeception/codeception/src/Codeception/Application.php:107
vendor/codeception/codeception/codecept:43
unit_testing/run_codecept:70
  • try 2:
There was 1 skipped test:
---------
1) CheckAffiliateTest: Check affiliate news sections
 Test  tests/unit/Api/CheckAffiliateTest.php:testCheckAffiliateNewsSections
This test depends on "Core\CheckNewsTest::testAddNewsSection" to pass.
  • try 3:
3) CheckAffiliateTest: Check affiliate news sections
 Test  tests/unit/Api/CheckAffiliateTest.php:testCheckAffiliateNewsSections
                                                                                                                                      
  [PHPUnit\Framework\Warning] This test depends on "Core\CheckAffiliateTest::CheckNewsTest:testAddNewsSection" which does not exist.  
                                                                                                                                      
vendor/phpunit/phpunit/src/Framework/TestCase.php:1973
vendor/phpunit/phpunit/src/Framework/TestCase.php:1886
vendor/phpunit/phpunit/src/Framework/TestCase.php:706
vendor/phpunit/phpunit/src/Framework/TestSuite.php:568
vendor/codeception/phpunit-wrapper/src/Runner.php:117
vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
vendor/codeception/codeception/src/Codeception/Codecept.php:193
vendor/codeception/codeception/src/Codeception/Codecept.php:160
vendor/codeception/codeception/src/Codeception/Command/Run.php:385
vendor/symfony/console/Command/Command.php:255
vendor/symfony/console/Application.php:921
vendor/symfony/console/Application.php:273
vendor/symfony/console/Application.php:149
vendor/codeception/codeception/src/Codeception/Application.php:107
vendor/codeception/codeception/codecept:43
unit_testing/run_codecept:70

  • try 4:
 Test  tests/unit/Api/CheckAffiliateTest.php:testCheckAffiliateNewsSections
                                                                                                              
  [PHPUnit\Framework\Warning] This test depends on "CheckNewsTest::testAddNewsSection" which does not exist.  
                                                                                                              
vendor/phpunit/phpunit/src/Framework/TestCase.php:1973
vendor/phpunit/phpunit/src/Framework/TestCase.php:1886
vendor/phpunit/phpunit/src/Framework/TestCase.php:706
vendor/phpunit/phpunit/src/Framework/TestSuite.php:568
vendor/codeception/phpunit-wrapper/src/Runner.php:117
vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
vendor/codeception/codeception/src/Codeception/Codecept.php:193
vendor/codeception/codeception/src/Codeception/Codecept.php:160
vendor/codeception/codeception/src/Codeception/Command/Run.php:385
vendor/symfony/console/Command/Command.php:255
vendor/symfony/console/Application.php:921
vendor/symfony/console/Application.php:273
vendor/symfony/console/Application.php:149
vendor/codeception/codeception/src/Codeception/Application.php:107
vendor/codeception/codeception/codecept:43
unit_testing/run_codecept:70

Provide test source code if related
CheckNewsTest.php

<?php
namespace Core;
use Codeception\Util\Fixtures;

class CheckNewsTest extends \Codeception\Test\Unit {
        /**
         * @var \UnitTester
         */
        protected $tester;
    public function testAddNewsSection(){
    }

CheckAffiliateTest.php:

<?php
namespace Core;
use Codeception\Util\Fixtures;

class CheckAffiliateTest extends \Codeception\Test\Unit {
        /**
        * @depends CheckNewsTest::testAddNewsSection
        */
        public function testCheckAffiliateNewsSections() {
    }

Details

  • Codeception version: 3.0.2 (also not working on 2.5.2 or 2.5.0)
  • PHP Version: 7.2.17-1+ubuntu14.04.1+deb.sury.org+3
  • Operating System: Ubuntu 14.04.6
  • Installation type: Composer
  • List of installed packages (composer show)
behat/gherkin                      v4.6.0     Gherkin DSL parser for PHP 5.3
codeception/codeception            3.0.2      BDD-style testing framework
codeception/phpunit-wrapper        8.0.4      PHPUnit classes used by Codeception
codeception/stub                   2.1.0      Flexible Stub wrapper for PHPUnit's Mock Builder
composer/semver                    1.5.0      Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler            1.3.3      Restarts a process without xdebug.
doctrine/instantiator              1.2.0      A small, lightweight utility to instantiate objects in PHP without invoking their constructors
facebook/webdriver                 1.7.1      A PHP client for Selenium WebDriver
felixfbecker/advanced-json-rpc     v3.0.3     A more advanced JSONRPC implementation
guzzlehttp/guzzle                  6.3.3      Guzzle is a PHP HTTP client library
guzzlehttp/promises                v1.3.1     Guzzle promises library
guzzlehttp/psr7                    1.6.1      PSR-7 message implementation that also provides common utility methods
hoa/consistency                    1.17.05.02 The Hoa\Consistency library.
hoa/console                        3.17.05.02 The Hoa\Console library.
hoa/event                          1.17.01.13 The Hoa\Event library.
hoa/exception                      1.17.01.16 The Hoa\Exception library.
hoa/file                           1.17.07.11 The Hoa\File library.
hoa/iterator                       2.17.01.10 The Hoa\Iterator library.
hoa/protocol                       1.17.01.14 The Hoa\Protocol library.
hoa/stream                         1.17.02.21 The Hoa\Stream library.
hoa/ustring                        4.17.01.16 The Hoa\Ustring library.
microsoft/tolerant-php-parser      v0.0.17    Tolerant PHP-to-AST parser designed for IDE usage scenarios
myclabs/deep-copy                  1.9.1      Create deep copies (clones) of your objects
netresearch/jsonmapper             v1.5.1     Map nested JSON structures onto PHP classes
phan/phan                          1.3.5      A static analyzer for PHP
phar-io/manifest                   1.0.3      Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    2.0.1      Library for handling version information and constraints
phpdocumentor/reflection-common    1.0.1      Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  4.3.1      With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in...
phpdocumentor/type-resolver        0.4.0     
phpspec/prophecy                   1.8.1      Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          7.0.6      Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          2.0.2      FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template          1.2.1      Simple template engine.
phpunit/php-timer                  2.1.2      Utility class for timing
phpunit/php-token-stream           3.0.2      Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    8.2.4      The PHP Unit Testing framework.
psr/container                      1.0.0      Common Container Interface (PHP FIG PSR-11)
psr/http-message                   1.0.1      Common interface for HTTP messages
psr/log                            1.1.0      Common interface for logging libraries
ralouphie/getallheaders            3.0.3      A polyfill for getallheaders.
sabre/event                        5.0.3      sabre/event is a library for lightweight event-based programming
sebastian/code-unit-reverse-lookup 1.0.1      Looks up which function or method a line of code belongs to
sebastian/comparator               3.0.2      Provides the functionality to compare PHP values for equality
sebastian/diff                     3.0.2      Diff implementation
sebastian/environment              4.2.2      Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 3.1.0      Provides the functionality to export PHP variables for visualization
sebastian/global-state             3.0.0      Snapshotting of global state
sebastian/object-enumerator        3.0.3      Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         1.1.1      Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        3.0.0      Provides functionality to recursively process PHP variables
sebastian/resource-operations      2.0.1      Provides a list of PHP built-in functions that operate on resources
sebastian/type                     1.1.3      Collection of value objects that represent the types of the PHP type system
sebastian/version                  2.0.1      Library that helps with managing the version number of Git-hosted PHP projects
symfony/browser-kit                v4.3.2     Symfony BrowserKit Component
symfony/console                    v4.3.2     Symfony Console Component
symfony/css-selector               v4.3.2     Symfony CssSelector Component
symfony/dom-crawler                v4.3.2     Symfony DomCrawler Component
symfony/event-dispatcher           v4.3.2     Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.5     Generic abstractions related to dispatching event
symfony/finder                     v4.3.2     Symfony Finder Component
symfony/polyfill-ctype             v1.11.0    Symfony polyfill for ctype functions
symfony/polyfill-mbstring          v1.11.0    Symfony polyfill for the Mbstring extension
symfony/polyfill-php73             v1.11.0    Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/process                    v4.3.2     Symfony Process Component
symfony/service-contracts          v1.1.5     Generic abstractions related to writing services
symfony/yaml                       v4.3.2     Symfony Yaml Component
theseer/tokenizer                  1.1.3      A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.4.0      Assertions to validate method input/output with nice error messages.
  • Suite configuration:
    codeception.yml
paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
settings:
    backup_globals: false

unit.suite.yml

 Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
    enabled:
        - \Helper\Unit
        - \Helper\FooRest
        - Asserts
        - Db:
           dsn: 'mysql:host=mysql;dbname=foo_test'
           user: 'access'
           password: 'acc123'
           reconnect: false
           dump: 'tests/_data/dump.sql'
           populate: true
           cleanup: false
           populator: 'mysql -u$user -h$host -p$password $dbname < $dump'
# custom configuration (move to codeception.dist.yml?)
# https://codeception.com/docs/reference/Configuration#Config-Templates-dist
error_level: "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions