跳转到主要内容

为使用ConfTools处理其配置的项目提供的测试工具。

项目描述

[![CircleCI](https://circleci.com/gh/AndreaCensi/comptests.svg?style=shield)](https://circleci.com/gh/AndreaCensi/comptests)

comptests
=========

基于[ConfTools][conftools]、[CompMake][compmake]和[QuickApp][quickapp]构建的测试工具。



基本用法
-----------

这是使用[ConfTools][conftools]注册对象的软件包的用法。

定义测试

调用函数 ``comptests_for_all`` 创建装饰器

获取库(ObjSpec)
library_robots = get_conftools_robots()

创建测试装饰器
for_all_robots = comptests_for_all(library_robots)

使用装饰器指定测试。测试函数
必须接受两个参数:id对象和对象本身

@for_all_robots
def check_robot_type(id_robot, robot)
assert isinstance(robot, RobotInterface)

您也可以为成对的对象注册测试

library_nuisances = get_conftools_nuisances()
for_all_robot_nuisance_pairs = comptests_for_all_pairs(library_robots, library_nuisances)

@for_all_robot_nuisance_pairs
def check_nuisances_obs(id_robot, robot, id_nuisance, nuisance)
check_conversions(robot.get_spec().get_observations(), nuisance)

运行测试

使用命令行

comptests <module>

This looks for the ``get_comptests()`` function in ``<module>``

def get_comptests()
get_comptests()
获取测试配置目录
from pkg_resources import resource_filename
dirname = resource_filename("boot_agents", "configs")
加载unittests
from . import unittests
from comptests import get_comptests_app
获取boot_config的Quickapp
app = get_comptests_app(get_boot_config())
return [app]

查找覆盖率信息
============================

将 ``coverage`` 工具与comptests一起使用非常有用。

安装 ``coverage`` 工具

pip install coverage

如果已安装“coverage”,则comptests将自动计算
nosetests执行的覆盖率信息。

要为comptests计算覆盖率信息,请按照以下方式运行

coverage run =comptests -c "make recurse=1" <package>

注意,您不能使用并行测试(使用“parmake”)否则
覆盖率将产生混淆。

这将显示结果

coverage report -m

然后创建HTML报告

coverage html -d outdir

项目详情


下载文件

下载适用于您平台文件的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

comptests-1.4.34.tar.gz (21.8 kB 查看哈希值)

上传时间

支持者