|
|
|
<!DOCTYPE html> |
|
<html lang="zh-cn"> |
|
<head> |
|
<meta charset="utf-8"/> |
|
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
|
<title>phpstorm集成phpunit - 小伢子 - 博客园</title> |
|
<link type="text/css" rel="stylesheet" href="/bundles/blog-common.css?v=-hy83QNg62d4qYibixJzxMJkbf1P9fTBlqv7SK5zVL01"/> |
|
<link id="MainCss" type="text/css" rel="stylesheet" href="/skins/coffee/bundle-coffee.css?v=NnZbvdgFaQNhu3t8P4Wsaz98sDQkgRt7Qxq2rzF0ZRU1"/> |
|
<link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="/skins/coffee/bundle-coffee-mobile.css?v=EhLLUe5NHsx18JODVZscd5ef3A8WbJHKTlTvuKQjsl01"/> |
|
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/baocheng/rss"/> |
|
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/baocheng/rsd.xml"/> |
|
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/baocheng/wlwmanifest.xml"/> |
|
<script src="//common.cnblogs.com/scripts/jquery-2.2.0.min.js"></script> |
|
<script type="text/javascript">var currentBlogApp = ‘baocheng‘, cb_enable_mathjax=false;var isLogined=false;</script> |
|
<script src="/bundles/blog-common.js?v=O-NTEmnhjbG7lSYLc3yeqkrVxfMJyY9iXf4xyjlKikw1" type="text/javascript"></script> |
|
</head> |
|
<body> |
|
<a name="top"></a> |
|
|
|
|
|
<div id="home"> |
|
<div id="header"> |
|
<div id="blogTitle"> |
|
<a id="lnkBlogLogo" href="http://www.cnblogs.com/baocheng/"><img id="blogLogo" src="/Skins/custom/images/logo.gif" alt="返回主页" /></a> |
|
|
|
|
|
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/baocheng/">小伢子</a></h1> |
|
<h2></h2> |
|
|
|
|
|
|
|
|
|
</div> |
|
</div> |
|
|
|
<div id="main"> |
|
<div id="mainContent"> |
|
<div class="forFlow"> |
|
<div id="navigator"> |
|
|
|
<ul id="navList"> |
|
<li><a id="blog_nav_sitehome" class="menu" href="http://www.cnblogs.com/">博客园</a></li> |
|
<li><a id="blog_nav_myhome" class="menu" href="http://www.cnblogs.com/baocheng/">首页</a></li> |
|
<li><a id="blog_nav_newpost" class="menu" rel="nofollow" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li> |
|
<li><a id="blog_nav_contact" accesskey="9" class="menu" rel="nofollow" href="https://msg.cnblogs.com/send/%E5%B0%8F%E4%BC%A2%E5%AD%90">联系</a></li> |
|
<li><a id="blog_nav_admin" class="menu" rel="nofollow" href="https://i.cnblogs.com/">管理</a></li> |
|
<li><a id="blog_nav_rss" class="menu" href="http://www.cnblogs.com/baocheng/rss">订阅</a> |
|
<a id="blog_nav_rss_image" class="aHeaderXML" href="http://www.cnblogs.com/baocheng/rss"><img src="//www.cnblogs.com/images/xml.gif" alt="订阅" /></a></li> |
|
</ul> |
|
|
|
|
|
<div class="blogStats"> |
|
|
|
<div id="blog_stats"> |
|
|
|
随笔- 97 |
|
文章- 0 |
|
评论- 10 |
|
</div> |
|
|
|
</div> |
|
</div> |
|
|
|
<div id="post_detail"> |
|
|
|
<div id="topics"> |
|
<div class = "post"> |
|
<h1 class = "postTitle"> |
|
<a id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/baocheng/p/5777287.html">phpstorm集成phpunit</a> |
|
</h1> |
|
<div class="clear"></div> |
|
<div class="postBody"> |
|
<div id="cnblogs_post_body" class="blogpost-body"><p>1.下载phpunit.phar,将该文件放到某个工程中</p> |
|
<p>2.File > Settings > Languages & Frameworks > PHP > PHPUnit<br />Path to phpunit.phar:选择该工程下的phpunit.phar文件</p> |
|
<p>3.新建文件夹src放源文件,tests放测试文件,在src中新建autoload.php</p> |
|
<div class="cnblogs_code"> |
|
<pre><?<span style="color: #000000;">php |
|
</span><span style="color: #0000ff;">function</span> __autoload(<span style="color: #800080;">$className</span><span style="color: #000000;">) |
|
{ |
|
</span><span style="color: #800080;">$filePath</span> = "src/{<span style="color: #800080;">$className</span>}.php"<span style="color: #000000;">; |
|
</span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">is_readable</span>(<span style="color: #800080;">$filePath</span><span style="color: #000000;">)) { |
|
</span><span style="color: #0000ff;">require</span>(<span style="color: #800080;">$filePath</span><span style="color: #000000;">); |
|
} |
|
} |
|
</span>?></pre> |
|
</div> |
|
<p><span style="line-height: 1.5;">4.要生成某个类的测试用例,点类名右键 > Go To > Test > Create New Test ,测试类的路径选择tests</span></p> |
|
<p>5.新建phpunit运行配置,Test Runner options添 --bootstrap src/autoload.php</p> |
|
<p>6.运行phpunit,如果提示interpreter is not specified,查看File > Settings > Languages & Frameworks > PHP 解释器是否设置</p></div><div id="MySignature"></div> |
|
<div class="clear"></div> |
|
<div id="blog_post_info_block"> |
|
<div id="BlogPostCategory"></div> |
|
<div id="EntryTag"></div> |
|
<div id="blog_post_info"> |
|
</div> |
|
<div class="clear"></div> |
|
<div id="post_next_prev"></div> |
|
</div> |
|
|
|
|
|
</div> |
|
<div class = "postDesc">posted @ <span id="post-date">2016-08-16 17:49</span> <a href=‘http://www.cnblogs.com/baocheng/‘>小伢子</a> 阅读(<span id="post_view_count">...</span>) 评论(<span id="post_comment_count">...</span>) <a href ="https://i.cnblogs.com/EditPosts.aspx?postid=5777287" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(5777287);return false;">收藏</a></div> |
|
</div> |
|
<script type="text/javascript">var allowComments=true,cb_blogId=179688,cb_entryId=5777287,cb_blogApp=currentBlogApp,cb_blogUserGuid=‘db265c11-f3a7-e211-83e8-90b11c0b17d6‘,cb_entryCreatedDate=‘2016/8/16 17:49:00‘;loadViewCount(cb_entryId);var cb_postType=1;</script> |
|
|
|
</div> |
|
</div><a name="!comments"></a><div id="blog-comments-placeholder"></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script> |
|
<div id=‘comment_form‘ class=‘commentform‘> |
|
<a name=‘commentform‘></a> |
|
<div id=‘divCommentShow‘></div> |
|
<div id=‘comment_nav‘><span id=‘span_refresh_tips‘></span><a href=‘javascript:void(0);‘ onclick=‘return RefreshCommentList();‘ id=‘lnk_RefreshComments‘ runat=‘server‘ clientidmode=‘Static‘>刷新评论</a><a href=‘#‘ onclick=‘return RefreshPage();‘>刷新页面</a><a href=‘#top‘>返回顶部</a></div> |
|
<div id=‘comment_form_container‘></div> |
|
<div class=‘ad_text_commentbox‘ id=‘ad_text_under_commentbox‘></div> |
|
<div id=‘ad_t2‘></div> |
|
<div id=‘opt_under_post‘></div> |
|
<div id=‘cnblogs_c1‘ class=‘c_ad_block‘></div> |
|
<div id=‘under_post_news‘></div> |
|
<div id=‘cnblogs_c2‘ class=‘c_ad_block‘></div> |
|
<div id=‘under_post_kb‘></div> |
|
<div id=‘HistoryToday‘ class=‘c_ad_block‘></div> |
|
<script type=‘text/javascript‘> |
|
fixPostBody(); |
|
setTimeout(function () { incrementViewCount(cb_entryId); }, 50); |
|
deliverAdT2(); |
|
deliverAdC1(); |
|
deliverAdC2(); |
|
loadNewsAndKb(); |
|
loadBlogSignature(); |
|
LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid); |
|
GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType); |
|
loadOptUnderPost(); |
|
GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate); |
|
</script> |
|
</div> |
|
|
|
|
|
</div> |
|
</div> |
|
|
|
<div id="sideBar"> |
|
<div id="sideBarMain"> |
|
|
|
|
|
<div class="newsItem"> |
|
<h3 class="catListTitle">公告</h3> |
|
<div id="blog-news"></div><script type="text/javascript">loadBlogNews();</script> |
|
</div> |
|
|
|
<div id="calendar"><div id="blog-calendar" style="display:none"></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div> |
|
|
|
<DIV id="leftcontentcontainer"> |
|
<div id="blog-sidecolumn"></div><script type="text/javascript">loadBlogSideColumn();</script> |
|
</DIV> |
|
|
|
</div> |
|
</div> |
|
<div class="clear"></div> |
|
</div> |
|
<div class="clear"></div> |
|
<div id="footer"> |
|
|
|
|
|
Copyright ©2018 小伢子 |
|
</div> |
|
</div> |
|
</body> |
|
</html> |
|
|