Running PHPUnit inside Docker does not store test metadata

docker
php

#1

We want to run PHPUnit inside the docker container. But the metadata is not created. It seems the problem is, that the created metadata of the tests is stored at the given path $CIRCLE_TEST_REPORTS/phpunit/junit.xml inside the container and therefore is not found.

test:
override:
- mkdir -p $CIRCLE_TEST_REPORTS/phpunit
- docker run -it $DOCKER_REPOSITORY:$DOCKER_TAG php vendor/bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml

Is there a way to store the metadata outside the container?


#2

If someone has a similar problem that’s how we have done it:

test:
override:

  • mkdir -p $CIRCLE_TEST_REPORTS/phpunit
  • docker run -it --name punit $DOCKER_REPOSITORY:$DOCKER_TAG php vendor/bin/phpunit --log-junit /tmp/phpunit/junit.xml
  • docker cp punit:/tmp/phpunit/junit.xml $CIRCLE_TEST_REPORTS/phpunit/junit.xml

#3