Icetea - 测试框架
项目描述
Icetea 测试框架
Icetea 是一个用于 Mbed 开发的自动化测试框架。它将 Mbed 板闪烁、运行测试和将测试结果累积到报告中的过程自动化。开发人员将其用于本地开发以及持续集成环境中的自动化。
在测试Mbed OS
Icetea 时,您可以通过CLI被测设备 ( ) 中的命令行界面 ( ) 远程执行命令DUT。测试框架之间的接口DUT可以是例如 UART 或 stdio。
有关该工具的更详细文档可 在此处以 rst 格式 和此处以降价格式获得。
先决条件
Icetea 支持 Linux(首选 Ubuntu)、Windows 和 OS X。我们的主要目标是 Linux。我们支持 Python 2.7 和 3.5 或更高版本。以下是一些特定于操作系统的先决条件:
-
Linux
- python-dev 和 python-lxml
sudo apt-get install python-dev python-lxml - 为了在没有 sudo 权限的 Linux 中使用硬件运行测试用例:
此命令会将用户“用户名”添加到“拨出”组并授予 USB 端口所需的权限。sudo usermod -a -G dialout username Log out & log in back to Linux
- python-dev 和 python-lxml
-
操作系统
- XCode 开发者工具
- MacPorts
- lxml:
STATIC_DEPS=true sudo pip install lxml
-
视窗
- python-lxml 安装在 Windows 上是有问题的,因为它通常需要构建工具。但是,它可以从预构建的二进制文件中安装。
- 从互联网上为您的系统搜索二进制文件。
- 导航到下载二进制文件的目录并安装它
pip install <insert_file_name>
- 您可以按照此处的说明进行操作 。
- python-lxml 安装在 Windows 上是有问题的,因为它通常需要构建工具。但是,它可以从预构建的二进制文件中安装。
可选的
有一些可选的依赖项带来了一些可选的特性,比如coloredlogs用各种颜色装饰你的控制台输出。
声明了所有可选的依赖项,extra_requirements.txt并且可以使用 pip 安装它们。请注意,您需要extra_requirements.txt本地文件。
> pip install -r extra_requirements.txt
皮鲨
嗅探器集成组件需要 pyshark,由于 trollius 的安装问题(python 2 版本的 pyshark 称为 pyshark-legacy 的要求),requirements.txt 中未涵盖该组件。要使用此集成,您需要为您的设置手动安装 pyshark。对于蟒蛇 3:
> pip install pyshark
对于蟒蛇 2:
> pip install pyshark-legacy
安装
> pip install icetea
用法
要打印帮助页:
icetea --help
要列出示例子文件夹中的所有本地测试用例:
icetea --list --tcdir examples
要打印 Icetea 版本:
icetea --version
典型用途
下面描述的所有命令可能还需要其他选项,具体取决于测试用例。
使用 tc 参数运行测试用例
> icetea --tc <test case name> --tcdir <test case search path>
要从文件夹运行所有现有测试用例examples:
> icetea --tc all --tcdir examples
使用硬件运行示例测试用例
在此示例中,我们假设已将兼容板连接到计算机,并且该板的应用程序二进制文件可用。引用的测试用例在icetea github 存储库中可用。
> icetea --tc test_cmdline --tcdir examples --type hardware --bin <path to a binary>
使用元数据过滤器
要在元数据中使用 testtype 回归运行所有测试用例:
> icetea --testtype regression --tcdir <test case search path>
可以使用以下元数据过滤器:
- 测试类型(--testtype)
- 测试子类型(--subtype)
- 特征(--特征)
- 测试用例名称 (--tc)
- 被测试的组件(--component)
- 测试用例文件夹(--group)
运行预制套件
Icetea 支持以格式描述一组测试用例的套件文件json。
> icetea --suite <suite file name> --tcdir <test case search path> --suitedir <path to suite directory>
启用调试级别日志记录
使用 -v 或 -vv 参数来控制日志记录级别。-v 将框架日志级别提高到调试(默认为 info),并将某些插件和外部组件的日志级别提高到 info(默认为警告)。--vv 增加所有 Icetea 记录器的日志记录级别以进行调试。
更多详细信息
有关任何功能的更多详细信息,请参阅我们的文档。
创建测试用例
Icetea 测试用例被实现为 Python 类,这些类继承了icetea_lib.bench模块中可用的 Bench 对象。测试用例需要有一个定义元数据的初始化函数和一个实现测试序列的用例函数。有两个可选功能,设置和拆卸。我们的文档中提供了更多信息。
一个示例测试用例如下所示:
"""
Copyright 2017 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from icetea_lib.bench import Bench
class Testcase(Bench):
def __init__(self):
Bench.__init__(self,
name="example_test",
title="Example test",
status="development",
purpose="Show example of a test",
component=["examples"],
type="smoke",
requirements={
"duts": {
'*': {
"count": 1,
"type": "hardware"
}
}
}
)
def setup(self):
# nothing for now
pass
def case(self):
self.command(1, "echo hello world", timeout=5)
self.command("help")
def teardown(self):
# nothing for now
pass
执照
请参阅许可协议。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。