下一代测试自动化。
ngta的Python项目详细描述
注释:
- 从1.0版开始,仅支持python>;=3.5.2。
- 从版本2.0开始,与UnitTest不兼容。
- 从4.0版开始,仅支持python>;=3.6.5。
介绍:
ngta的全称是下一代测试自动化,它的设计关键字如下:
- 独立经营
- 跨平台。
- 强大的testcase参数化。
- 添加测试台概念
- 添加事件机制。
- 本地模式:
- 使用schema的强大的yml配置。
- HTML报表可以扩展和自定义
- 当testbench不是独占的时,支持用多进程运行测试用例。
- 代理模式:
安装
- 安装NGTA:
pip install ngta
- 生成工作目录:
python -m ngta init --dest-dir=${WORKDIR} --include-sample
注意:${workdir}表示目标目录。
为什么我们需要工作目录:
- 测试代码也需要版本控制,请使用git。
- 良好的工作结构有助于测试用例的管理
生成的工作目录:
${WORKDIR} root dir
|-- bin
|-- agent.exe exe file for installing test agent as service in Windows.
|-- agent.service systemd service file for linux.
|-- agent.xml the config file for installing as service in Windows.
|-- cases tesetcase dir
|-- sample1 project or product dir1(GIT submodule1)
|-- sample2 project or product dir2(GIT submodule2)
|-- conf agent config files
|-- lib internal libraries.
|-- logs userd for saving log, result and report.
|-- .ngta anchor file, also used to store configuration.
节点:为了与平台集成,将每个项目或产品创建为git存储库,并将其作为git子模块放入${workdir}/cases中。
示例:按yml config
运行测试- 打开命令行,运行以下命令:
cd ${WORKDIR}
python -m ngta run --config=cases\sample\base\config.yml - 运行完成后,我们可以在
${WORKDIR}\logs
中找到日志和报表。 - 在
${WORKDIR}\cases\sample\base\config.xml
中,它配置如何在${WORKDIR}\cases\sample\base\test_equal.py
中加载测试并注入参数
示例:按路径运行测试
- 打开命令行,运行以下命令:
cd ${WORKDIR}
python -m ngta run --locate=sample.base.test_equal - 运行完成后,我们可以在
${WORKDIR}\logs
中找到日志和报表
注释:
--locate
可以是package
、module
、class
、method
、py file
或dir
。- 当指定
--locate
时,它还支持其他参数--tag
、--include
、--failfast
、--repeat-number
等。
示例:run.py文件
- 打开命令行,运行以下命令:
cd ${WORKDIR}\cases\sample\base
python test_equal.py - 运行完成后,可以在
${WORKDIR}\cases\sample\base
中找到report.html
。
与unittest.testcase不同:
复习${WORKDIR}\cases\sample\base\test_equal.py
:
# coding: utf-8fromngtaimportTestCase,tag,testclassEqualTestCase(TestCase):@tag("regression")@test(u"Test {value1} equal with {value2}")deftest_int(self,value1=1,value2=2):msg="%s should equal with %s."%(value1,value2)self.assert_that(value1,msg).is_equal_to(value2)
@tag
指定标记regression
@test
用于指定这是一个测试用例。assert_that
引用:assertpy
报告示例:
- 截图:
- html:report.html
更多功能:Guide