douxin1884 2016-08-15 05:39
浏览 79
已采纳

如何使用Bluemix构建和部署测试作业与PHP单元测试

I am trying to setup a build and deploy pipeline on Bluemix for my PHP application. I am using PHPUnit for testing but can't seem to get the test stage to call PHPUnit because it isn't installed. The Build and Deploy stages work perfectly for me I am just trying to add a test stage between them. The problem is that PHP isn't even installed in the test stage. I quick php -v will give a command not found error. Do I have to install php, apache, composer, and phpunit just to get this test stage to work? Is there a better way to do this?

  • 写回答

2条回答 默认 最新

  • doushoubu5360 2016-08-17 00:05
    关注

    I ended up installing apache, php7, and composer in order to get phpunit working. Here are the commands I ran during a test stage. There are some echo and ls statements that I was using to help me debug the installations. My tests are under the tests folder in the root of my directory like test/exampleTest.php and I have phpunit create an xml output file called tests/Test.xml and then supply that file to the box asking "Test Result File Pattern" so then Bluemix can read that file to know if the Tests succeeded or failed.

    #!/bin/bash
    # invoke tests here
    echo "  adding repo"
    sudo add-apt-repository ppa:ondrej/php
    echo "  updating apt-get"
    sudo apt-get -y update
    echo " installing apache2"
    sudo apt-get -y install apache2
    echo " installing php7.0"
    sudo apt-get -y --force-yes install php7.0 libapache2-mod-php7.0 php7.0-xml php7.0-cli php7.0-common php7.0-fpm php7.0-curl php7.0-gd php7.0-bz2
    echo " PHP TESTING"
    php -v
    echo " PHP TESTING 2"
    php -r 'echo "
    
    Your PHP installation is working fine.
    
    
    ";'
    echo "  downloading composer"
    curl -sS https://getcomposer.org/installer | php
    echo "  installing composer"
    php composer.phar install
    echo "  ls"
    ls
    echo "  ls ../"
    ls ../
    echo "  ls vendor"
    ls vendor
    echo "  running tests"
    vendor/bin/phpunit --log-junit tests/Test.xml --bootstrap vendor/autoload.php tests
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写