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

相关文章

Java中 instanceof 的用法详细介绍

《Java中instanceof的用法详细介绍》在Java中,instanceof是一个二元运算符(类型比较操作符),用于检查一个对象是否是某个特定类、接口的实例,或者是否是其子类的实例,这篇文章... 目录引言基本语法基本作用1. 检查对象是否是指定类的实例2. 检查对象是否是子类的实例3. 检查对象是否

Java中的内部类和常用类用法解读

《Java中的内部类和常用类用法解读》:本文主要介绍Java中的内部类和常用类用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录内部类和常用类内部类成员内部类静态内部类局部内部类匿名内部类常用类Object类包装类String类StringBuffer和Stri

Python 异步编程 asyncio简介及基本用法

《Python异步编程asyncio简介及基本用法》asyncio是Python的一个库,用于编写并发代码,使用协程、任务和Futures来处理I/O密集型和高延迟操作,本文给大家介绍Python... 目录1、asyncio是什么IO密集型任务特征2、怎么用1、基本用法2、关键字 async1、async

浅析如何使用xstream实现javaBean与xml互转

《浅析如何使用xstream实现javaBean与xml互转》XStream是一个用于将Java对象与XML之间进行转换的库,它非常简单易用,下面将详细介绍如何使用XStream实现JavaBean与... 目录1. 引入依赖2. 定义 JavaBean3. JavaBean 转 XML4. XML 转 J

SpringBoot3.4配置校验新特性的用法详解

《SpringBoot3.4配置校验新特性的用法详解》SpringBoot3.4对配置校验支持进行了全面升级,这篇文章为大家详细介绍了一下它们的具体使用,文中的示例代码讲解详细,感兴趣的小伙伴可以参考... 目录基本用法示例定义配置类配置 application.yml注入使用嵌套对象与集合元素深度校验开发

SpringBoot UserAgentUtils获取用户浏览器的用法

《SpringBootUserAgentUtils获取用户浏览器的用法》UserAgentUtils是于处理用户代理(User-Agent)字符串的工具类,一般用于解析和处理浏览器、操作系统以及设备... 目录介绍效果图依赖封装客户端工具封装IP工具实体类获取设备信息入库介绍UserAgentUtils

Java中的@SneakyThrows注解用法详解

《Java中的@SneakyThrows注解用法详解》:本文主要介绍Java中的@SneakyThrows注解用法的相关资料,Lombok的@SneakyThrows注解简化了Java方法中的异常... 目录前言一、@SneakyThrows 简介1.1 什么是 Lombok?二、@SneakyThrows

Python中的getopt模块用法小结

《Python中的getopt模块用法小结》getopt.getopt()函数是Python中用于解析命令行参数的标准库函数,该函数可以从命令行中提取选项和参数,并对它们进行处理,本文详细介绍了Pyt... 目录getopt模块介绍getopt.getopt函数的介绍getopt模块的常用用法getopt模

Python利用ElementTree实现快速解析XML文件

《Python利用ElementTree实现快速解析XML文件》ElementTree是Python标准库的一部分,而且是Python标准库中用于解析和操作XML数据的模块,下面小编就来和大家详细讲讲... 目录一、XML文件解析到底有多重要二、ElementTree快速入门1. 加载XML的两种方式2.

mysql中的group by高级用法

《mysql中的groupby高级用法》MySQL中的GROUPBY是数据聚合分析的核心功能,主要用于将结果集按指定列分组,并结合聚合函数进行统计计算,下面给大家介绍mysql中的groupby用法... 目录一、基本语法与核心功能二、基础用法示例1. 单列分组统计2. 多列组合分组3. 与WHERE结合使