我爲Laravel 5.5項目(帖子底部的文件)設置了Gitlab CI管道,並且構建成功,但測試失敗,因爲PHPUnit與錯誤信息Gitlab CI -Laravel 5.5 - PHPUnit「Tests TestCase not found」
Fatal error: Class 'Tests\TestCase' not found in /builds/[User]/[Repo]/tests/Feature/DocumentTest.php on line 8
退出(顯然,[用戶]和[回購]是不是真正的價值,只是不想把它公開在這裏)
我已經嘗試過不同的東西,就像全局安裝PHPUnit一樣,以不同的方式調用PHPUnit,它都會以相同的錯誤信息結束。
PHPUnit在我的本地運行成功(不管我怎麼稱呼它,它總是有效的)。所以任何人都知道這裏的問題可能是什麼?
僅供參考這裏的管道文件:
.gitlab-ci.yml:
image: woohuiren/php-laravel-env:latest
services:
- mysql:latest
- redis:4.0.2-alpine
before_script:
- apk update
- docker-php-ext-install pcntl
variables:
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: root
stages:
- build
- test
build_job:
stage: build
script:
- sh .gitlab-build.sh
artifacts:
paths:
- vendor/
- bootstrap/
- composer.phar
- .env
tags:
- docker
test_job:
stage: test
dependencies:
- build_job
script:
- sh .gitlab-ci.sh
tags:
- docker
.gitlab-build.sh:
#!/bin/bash
set -eo pipefail
php -v
ping -c 3 mysql
php composer.phar install --no-progress --no-scripts
php artisan package:discover
cp -v .env.testing .env
php artisan key:generate
php artisan optimize
php artisan config:clear
php artisan storage:link
php artisan migrate --seed
php artisan jwt:secret
php artisan passport:install --force
。 gitlab-ci.sh:
#!/bin/sh
set -eo pipefail
php -v
ping -c 3 mysql
./vendor/phpunit/phpunit/phpunit -v --testdox
嘿對不起,遲交回復。沒有你的答案沒有解決問題。不管怎麼說,還是要謝謝你! –
謝謝,1月你介意分享你如何解決問題?我有興趣瞭解是什麼導致了這個問題。 –
沒有解決辦法,我很害怕。我很樂意更新這個線程,如果有的話,我會解決它,但我假設你會得到一個通知,如果我曾經這樣做? –