gigascience / gigadb-website

Source code for running GigaDB
http://gigadb.org
GNU General Public License v3.0
9 stars 15 forks source link

Errors when running unit tests #2011

Open pli888 opened 2 months ago

pli888 commented 2 months ago

There are sometimes error messages when running unit tests in the dev environment which were observed when reviewing PR #1987.

To reproduce the problem:

  1. Run ./up.sh to start dev GigaDB instance.
  2. Run RelationDAOTest unit test:

    
    docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit RelationDAOTest
    1) RelationDAOTest: Itshould add reciprocal relation | #0
    Test  tests/unit/RelationDAOTest.php:testItshouldAddReciprocalRelation
    
    [PHPUnit_Framework_Exception] Trying to get property 'id' of non-object  

1 /var/www/protected/models/RelationDAO.php:64

2 /var/www/tests/unit/RelationDAOTest.php:65

3 RelationDAOTest->testItshouldAddReciprocalRelation



However, running all unit tests by executing `docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit` will allow `RelationDAOTest` to pass. If you then run `docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit RelationDAOTest` then this will pass too.

Feels like running `docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit` makes `docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit RelationDAOTest` use test data in `protected/tests/fixtures`. If you execute `docker-compose run --rm test ./vendor/codeception/codeception/codecept run unit RelationDAOTest` immediately after `./up.sh` then dev data is used in unit tests which may be related to why it was sometimes failing for me.