简体   繁体   English

与Laravel包和Behat持续集成

[英]Continuous integration with Laravel package and Behat

I'm developing a package for Laravel which actually needs the whole Laravel application to run the tests I wrote with Behat. 我正在为Laravel开发一个包,它实际上需要整个Laravel应用程序来运行我用Behat编写的测试。

I'm using Travis as a CI service and I wonder if there is a specific .travis.yml configuration to let the tests created for my package run with a newly created Laravel application. 我正在使用Travis作为CI服务,我想知道是否存在特定的.travis.yml配置,以便为我的包创建测试,并使用新创建的Laravel应用程序运行。

Basically my package consists in a trait for console commands that cannot be tested without installing Laravel itself. 基本上我的包包含一个控制台命令的特性,如果不安装Laravel本身就无法测试。

I know I can install a new Laravel application by setting the install hook in .travis.yml but then I don't know how to integrate and run my tests with the app. 我知道我可以通过在.travis.yml设置install挂钩来安装新的Laravel应用程序,但后来我不知道如何与应用程序集成和运行我的测试。

I'm gonna share with you my travis config file (I am using Laravel 5.1). 我要与你分享我的travis配置文件(我正在使用Laravel 5.1)。

My file works with PHPUnit however just replace the line that runs PHPUnit with your Behat command, everything else is perfect. 我的文件适用于PHPUnit,但只需用Behat命令替换运行PHPUnit的行,其他一切都很完美。

.travis.yml .travis.yml

language: php

php:
  - 5.5.9
  - 5.6
  - 7.0
  - hhvm

matrix:
    allow_failures:
        - php: hhvm

before_script:
- cp .env.travis .env
- mysql -e 'create database homestead;'
- composer self-update
- composer install --prefer-source --no-interaction --dev
- php artisan migrate
- php artisan db:seed

script: vendor/bin/phpunit

You must include .env.travis as well, a sample file would look like this: 您还必须包含.env.travis ,示例文件如下所示:

APP_ENV=testing
APP_DEBUG=true
APP_KEY=xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

you can of course use specific DB_CONNECTION that probably runs with sqlite in memory or so.. 你当然可以使用特定的DB_CONNECTION ,它可能在内存中运行sqlite等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM