phpunit.xml 用法

2023-10-29 00:58
文章标签 xml 用法 phpunit

本文主要是介绍phpunit.xml 用法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

phpunit.xml 用法

分类: phpunit   842人阅读  评论(0)  收藏  举报
测试 action junit xml logging json
<phpunit bootstrap="./booten.php">

    <testsuite name="actionsuitetest">
      <directory suffix=".php">action</directory>

      <file>HuiyuanZhanghuOrder.php</file>

     <exclude>/action/HuiyuanJifenTest.php</exclude>

    </testsuite>
    
    <testsuite name="modelsuitetest">
      <directory suffix=".php">model</directory>
    </testsuite>
    
    <testsuite name="htmlsuitetest">
      <directory suffix=".php">html</directory>
    </testsuite>

    <!-- 代码覆盖率 -->
    <!-- 覆盖率的测试文件,blacklist 黑名单(不需要统计覆盖率的文件),whitelist 白名单(统计覆盖率的测试文件) 当黑名单与白名单文件重复时,白名单起作用 
    
    -->
    <filter>
<blacklist>
    <directory suffix=".php">action</directory>
    <file>ArrayTest.php</file>
   </blacklist>
  
  <whitelist addUncoveredFilesFromWhitelist="true">
    <directory suffix=".php">action</directory>
    <directory suffix=".php">model</directory>
    <directory suffix=".php">html</directory>
    <file>ArrayTest.php</file>
    <exclude>
    <directory suffix=".php">action/lib</directory>
    <directory suffix=".php">model</directory>
    <file>action/lib/Loginxxx.php</file>
    </exclude>
   </whitelist>
</filter>
    
    <!--代码覆盖率报告,可以生成很多类型报告,有html(coverage-html),xml(coverage-clover),txt ,json 等等  
    <log type="coverage-php" target="/tmp/coverage.serialized"/>
  <log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
  <log type="json" target="/tmp/logfile.json"/>
  <log type="tap" target="/tmp/logfile.tap"/>
  <log type="junit" target="/tmp/logfile.xml" logIncompleteSkipped="false"/>
  <log type="testdox-html" target="/tmp/testdox.html"/>
  <log type="testdox-text" target="/tmp/testdox.txt"/>
    
    -->
    
        <logging>
         <!-- target(report/html) 生成html 文件的目录-->
   <log type="coverage-html" target="report/html" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
   <!-- target(report/coverage/coverage.xml) 生成xml的文件名-->
   <log type="coverage-clover" target="report/coverage/coverage.xml"/>
</logging>
    <!-- 代码覆盖率 -->



    <php>
 <includePath>.</includePath>
 <ini name="foo" value="bar"/>
 <const name="foo" value="bar"/>
 <var name="foo" value="bar"/>
 <env name="foo" value="bar"/>
 <post name="foo" value="bar"/>
 <get name="foo" value="bar"/>
 <cookie name="foo" value="bar"/>
 <server name="foo" value="bar"/>
 <files name="foo" value="bar"/>
 <request name="foo" value="bar"/>
</php>  

</phpunit>


xml 解释

bootstrap="./booten.php"

在测试之前加载的的PHP 文件,一般可以做一个初始化工作


<testsuite name="actionsuitetest">
      <directory suffix=".php">action</directory>
      <file>HuiyuanZhanghuOrder.php</file>
</testsuite>

测试套件,如果想测试页面,action,model 可以多加几个测试套件

name: 套件名称

directory :套件测试的目录,目录下一般放测试文件的用例

       suffix :测试文件后缀,如果不填写,则默认后缀为*Test.php,即phpunit 默认会执行*Test.php  的文件

       action:测试目录名

file:可以单独设置测试文件

exclude:排除不需要测试的文件



 <php>
  <includePath>.</includePath>
  <ini name="foo" value="bar"/>
  <const name="foo" value="bar"/>
  <var name="foo" value="bar"/>
  <env name="foo" value="bar"/>
  <post name="foo" value="bar"/>
  <get name="foo" value="bar"/>
  <cookie name="foo" value="bar"/>
  <server name="foo" value="bar"/>
  <files name="foo" value="bar"/>
  <request name="foo" value="bar"/>
</php>  

这段xml 可以对应以下PHP 代码

includePath

ini_set('foo', 'bar');
define('foo', 'bar');
$GLOBALS['foo'] = 'bar';
$_ENV['foo'] = 'bar';
$_POST['foo'] = 'bar';
$_GET['foo'] = 'bar';
$_COOKIE['foo'] = 'bar';
$_SERVER['foo'] = 'bar';
$_FILES['foo'] = 'bar';
$_REQUEST['foo'] = 'bar';


phpunit.xml 应用网址http://www.phpunit.de/manual/3.6/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist

版权声明:本文为博主原创文章,未经博主允许不得转载。

这篇关于phpunit.xml 用法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/297163

相关文章

MySQL中between and的基本用法、范围查询示例详解

《MySQL中betweenand的基本用法、范围查询示例详解》BETWEENAND操作符在MySQL中用于选择在两个值之间的数据,包括边界值,它支持数值和日期类型,示例展示了如何使用BETWEEN... 目录一、between and语法二、使用示例2.1、betwphpeen and数值查询2.2、be

springboot中配置logback-spring.xml的方法

《springboot中配置logback-spring.xml的方法》文章介绍了如何在SpringBoot项目中配置logback-spring.xml文件来进行日志管理,包括如何定义日志输出方式、... 目录一、在src/main/resources目录下,也就是在classpath路径下创建logba

Java序列化之serialVersionUID的用法解读

《Java序列化之serialVersionUID的用法解读》Java序列化之serialVersionUID:本文介绍了Java对象的序列化和反序列化过程,强调了serialVersionUID的作... 目录JavChina编程a序列化之serialVersionUID什么是序列化为什么要序列化serialV

python3中正则表达式处理函数用法总结

《python3中正则表达式处理函数用法总结》Python中的正则表达式是一个强大的文本处理工具,用于匹配、查找、替换等操作,在Python中正则表达式的操作主要通过内置的re模块来实现,这篇文章主要... 目录前言re.match函数re.search方法re.match 与 re.search的区别检索

MySQL 中的 JSON_CONTAIN用法示例详解

《MySQL中的JSON_CONTAIN用法示例详解》JSON_CONTAINS函数用于检查一个JSON文档中是否包含另一个JSON文档,这篇文章给大家介绍JSON_CONTAINS的用法、语法、... 目录深入了解 mysql 中的 jsON_CONTAINS1. JSON_CONTAINS 函数的概述2

MyBatis常用XML语法详解

《MyBatis常用XML语法详解》文章介绍了MyBatis常用XML语法,包括结果映射、查询语句、插入语句、更新语句、删除语句、动态SQL标签以及ehcache.xml文件的使用,感兴趣的朋友跟随小... 目录1、定义结果映射2、查询语句3、插入语句4、更新语句5、删除语句6、动态 SQL 标签7、ehc

JDK21对虚拟线程的几种用法实践指南

《JDK21对虚拟线程的几种用法实践指南》虚拟线程是Java中的一种轻量级线程,由JVM管理,特别适合于I/O密集型任务,:本文主要介绍JDK21对虚拟线程的几种用法,文中通过代码介绍的非常详细,... 目录一、参考官方文档二、什么是虚拟线程三、几种用法1、Thread.ofVirtual().start(

Java8 Collectors.toMap() 的两种用法

《Java8Collectors.toMap()的两种用法》Collectors.toMap():JDK8中提供,用于将Stream流转换为Map,本文给大家介绍Java8Collector... 目录一、简单介绍用法1:根据某一属性,对对象的实例或属性做映射用法2:根据某一属性,对对象集合进行去重二、Du

Python中isinstance()函数原理解释及详细用法示例

《Python中isinstance()函数原理解释及详细用法示例》isinstance()是Python内置的一个非常有用的函数,用于检查一个对象是否属于指定的类型或类型元组中的某一个类型,它是Py... 目录python中isinstance()函数原理解释及详细用法指南一、isinstance()函数

Python中的sort方法、sorted函数与lambda表达式及用法详解

《Python中的sort方法、sorted函数与lambda表达式及用法详解》文章对比了Python中list.sort()与sorted()函数的区别,指出sort()原地排序返回None,sor... 目录1. sort()方法1.1 sort()方法1.2 基本语法和参数A. reverse参数B.