一、环境

系统: windows10

WampServer:  wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe

IDE:  IntelliJ IDEA 2017.3.2

PHP: 7.1.15

Intellij IDEA 如何支持php请参考,IntellIJ IDEA 配置 Vue 支持

二、PHPunit配置

1.下载PHPunit.phar:

Linux:

➜ wget -O phpunit https://phar.phpunit.de/phpunit-7.phar

➜ chmod +x phpunit

➜ ./phpunit --version

Window:

下载phpunit-7.phar到你所在的php.exe目录下, 并新建外包覆批处理脚本 phpunit.cmd 文件,内容如下:

@ECHO OFF
php %~dp0phpunit-.phar %*

对于 Cygwin 或 MingW32 (例如 TortoiseGit) shell 环境, 取而代之的是,把文件保存为 phpunit (没有 .phar 扩展名),然后用 chmod 775 phpunit 将其设为可执行。参考:安装 PHPUnit

设置环境变量:

执行: phpunit --version

PS: https://phpunit.de/getting-started/phpunit-7.html

三、新建测试项目

1.以Yii 项目为例,在protected目录下创建一个测试目录tests。在tests目录下创建bootstrap.php文件。

<?php
define('YII_ENV', 'test');
defined('YII_DEBUG') or define('YII_DEBUG', true);
require_once(__DIR__ . '/../../../yiisoft/yii2/Yii.php');
$config = require '../config/web.php';
(new Application($config));

bootstrap文件是用来加载测试用例的运行时用的,各个项目有各个项目的加载配置,按具体项目而定。

2.编写测试用例

<?php

use PHPUnit\Framework\TestCase;

class MyTest extends TestCase{

    public function testEmpty(){
$stack = []; $this->assertEmpty($stack); return $stack;
}
}

在测试用例中需要注意的是命名空间还是需要指定的。参考:编写 PHPUnit 测试

三、配置PHPunit

1. 勾选 Default bootstrap file ,并选择你上文新建的 bootstrap.php 文件。

2. 在你所在的 MyTest.php 文件 testEmpty 方法体中, 点击右键选择执行 。

如果你想手动执行:

D:\IdeaProjects>phpunit --bootstrap D:\IdeaProjects\test\protected\tests\bootstrap.php MyTest D:\IdeaProjects\test\protected\tests\examples\MyTest.php
PHPUnit 7.1. by Sebastian Bergmann and contributors. . / (%) Time: ms, Memory: .00MB OK ( test, assertion)

PS:

http://www.yii-china.com/post/detail/460.html

http://tangl163.iteye.com/blog/2288538

https://phpunit.readthedocs.io/zh_CN/latest/installation.html

https://phpunit.readthedocs.io/zh_CN/latest/index.html

https://phpunit.de/getting-started/phpunit-7.html

Windows10 + IntelliJ IDEA 2017.3.2 + wamp2e + Yii + PHPunit 搭建测试环境的更多相关文章

  1. Windows10 + IntelliJ IDEA 2017.3.2 + wamp2e + xdebug 调试 配置

    一.环境 系统: windows10 WampServer:  wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe IDE:  Intel ...

  2. Intellij IDEA 2017 详细图文教程之概述

    天天编码 , 版权所有丨本文标题:Intellij IDEA 2017 详细图文教程之概述 转载请保留页面地址:http://www.tiantianbianma.com/intellij-idea- ...

  3. IntelliJ IDEA 2017 注册方法

    本文使用破解方式注册. JetbrainsCrack-2.6.2.jar适用于ideaIU-2017.2.之前版本,若下载的版本较新破解文件可能无法使用,破解时一闪而退. 其中JetbrainsCra ...

  4. intellij idea 2017和Jprofiler 10的集成 报错问题

    本来想用Jprofiler来分析一下自己写的Java项目,以提高代码执行效率和自己的编码能力.结果,官网和网上很多帖子都写了点出session->IDE integrations->选择i ...

  5. IntelliJ IDEA 2017新工具

    IntelliJ IDEA 2017 教程之概述 图文详解如何安装 Intellij IDEA 2017 深入剖析 IntelliJ IDEA 2017 的目录结构 图文详解如何配置 IntelliJ ...

  6. IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目

    IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目 1.确认 IDEA 是否启用了 tomcat 插件 2.添加 tomcat 选择 tomcat 存放路 ...

  7. IntelliJ IDEA 2017.3.1安装步骤

    https://www.jetbrains.com/idea/download/#section=windows 下载旗舰版 1.下载完成后,运行安装: 2.next: 3.选择你要安装的目录,nex ...

  8. IntelliJ IDEA 2017 永久注册方法

    https://blog.csdn.net/weixin_39913200/article/details/80859897 在安装的idea下面的bin目录下面有2个文件 : 一个是idea64.e ...

  9. Idea for Mac 过期 IntelliJ IDEA 2017 完美注册方法(附idea for Mac破解方法)

    Idea 不能使用了: 开始破解: (1)首先下载 jar包: https://download.csdn.net/download/engerla/10573069 放到位置: /Applicati ...

随机推荐

  1. 爬虫——request

    命名规范 module_name,模块 package_name,包 ClassName,类 method_name,方法 ExceptionName,异常 function_name,函数 GLOB ...

  2. fast-fail事件的产生及其解决办法

    1.fail-fast事件出现的情景 import java.util.*; import java.util.concurrent.*; /* * * * fail-fast事件产生的条件:当多个线 ...

  3. Ubuntu1404 开启定时任务 crontab

    crontab -e 这个 我使用vim编辑,所以选择3,进入到 写了两条,的确隔了一分钟在test.txt文件夹里面会多加一条Good morning进去.而且也会执行dingshi.sh这个she ...

  4. CSS_盒子模型

    2016-10-22 <css入门经典>第6章 1.每个HTML元素对应于一个显示盒子,但不是所有的元素都显示在屏幕上. 2.HTML元素显示为CSS显示盒子的真正方法称为“可视格式化方式 ...

  5. [原创]AndroBugs_Framework Android漏洞扫描器介绍

    [原创]AndroBugs_Framework Android漏洞扫描器介绍 1 AndroBugs_Framework Android 漏洞扫描器简介 一款高效的Android漏洞扫描器,可以帮助开 ...

  6. jquery动态添加元素无法触发绑定的事件的解决方案

    方法一:绑定live事件(live事件只在jquery1.9以下才支持,高版本不支持). //jquery 1.9(不包括1.9)以下可以 $(".btn").live(" ...

  7. 一步步教你轻松学K-means聚类算法

    一步步教你轻松学K-means聚类算法(白宁超  2018年9月13日09:10:33) 导读:k-均值算法(英文:k-means clustering),属于比较常用的算法之一,文本首先介绍聚类的理 ...

  8. API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'

    WARNING: API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaComp ...

  9. linux服务器挂掉自动重启脚本(转)

    实现原理主要是使用linux提供的crontab机制,定时查询服务器进程是否存在,如果宕机则执行我们预设的重启脚本. 首先我们要向crontab加入一个新任务 sudo crontab -e #进入编 ...

  10. 【Docker江湖】之docker部署与理解

    转载请注明出处:http://blog.csdn.net/gamer_gyt 博主微博:http://weibo.com/234654758 Github:https://github.com/thi ...