LoginSignup
2
1

More than 5 years have passed since last update.

TravisClでLaravel5.2のテストを自動化してみる

Last updated at Posted at 2016-11-11

TravisClでLaravel5.2のテストを自動化を試してみた。

##環境
テスト対象FW:Laravel 5.2
DB:Postgresql
開発環境:Laravel/homestead v0.5.0
ローカル環境:Windows10

##下準備
プロジェクトのルートディレクトリに
①.env.travis
②.travis.yml
の2ファイルを作成

##.env.travis

.env.travis
APP_ENV=testing
APP_DEBUG=true
APP_KEY=
APP_URL=http://localhost

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=travis_ci_test
DB_USERNAME=postgres
DB_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

##.travis.yml

.travis.yml
language: php

php:
    - 7.0

services:
    - postgresql

before_script:
    - cp .env.travis .env
    - psql -c 'create database travis_ci_test;' -U postgres
    - composer self-update
    - composer install --no-interaction
    - php artisan key:generate
    - php artisan migrate

script:
    - phpunit

上記を記述後GitHubへpushするだけでテストがTravisCl上で実行される。

##参考
TravisCl公式ドキュメント
stackoverflow

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1