测试教程网.unittest教程.6. 命令行接口
From: http://www.testclass.net/pyunit/commind_line_interface/
背景
unittest支持命令行接口,我们可以在命令行里指定运行具体的测试用例。
实例
在test_password_1.py中定义了PasswordTeseCase用例,我们可以从命令行中指定只运行该用例。
$ python -m unittest test_password_1.PasswordTeseCase
set up
.set up
F
======================================================================
FAIL: test_week_password (test_password_1.PasswordTeseCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/easonhan/code/testclass.net/src/pyunit/test_password_1.py", line 21, in test_week_password
self.assertTrue(passwd != 'password123', msg)
AssertionError: False is not true : user tom has a weak password
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (failures=1)
还可以使用-v参数来获得更详细的输出
$ python -m unittest test_password_1.PasswordTeseCase -v
test_dummy (test_password_1.PasswordTeseCase) ... set up
ok
test_week_password (test_password_1.PasswordTeseCase) ... set up
FAIL
======================================================================
FAIL: test_week_password (test_password_1.PasswordTeseCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/easonhan/code/testclass.net/src/pyunit/test_password_1.py", line 21, in test_week_password
self.assertTrue(passwd != 'password123', msg)
AssertionError: False is not true : user tom has a weak password
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (failures=1)
也可以在命令行中一次指定多个测试用例类,具体的大家可以自己尝试一下。
测试教程网.unittest教程.6. 命令行接口的更多相关文章
- 测试教程网.unittest教程.2. 基本用法
From: http://www.testclass.net/pyunit/basic_example/ 我们通过最简单的例子来看一下unittest的基本用法,下面的代码测试了3个python字符串 ...
- 测试教程网.unittest教程.3. 实例: 测试弱密码
From: http://www.testclass.net/pyunit/test_example_1/ 背景 考虑这样一个测试弱密码的实例,这个我们在pytest相关教程中也有过描述. 我们需要判 ...
- 测试教程网.unittest教程.5. 实例: 找出所有是弱密码的用户
From: http://www.testclass.net/pyunit/test_example_3/ 背景 当我们的测试数据是下面这些的时候,我们的用例是有问题的. [ {"name& ...
- 测试教程网.unittest教程.4. 实例: 读取测试数据并测试弱密码
From: http://www.testclass.net/pyunit/test_example_2/ 背景 接上一节的弱密码例子,我们的用例尽管运行的不错,但还是有点问题. 假如我们需要增加一些 ...
- 测试教程网.unittest教程.1. 基本概念
From:http://www.testclass.net/pyunit/basic_concept/ unittest是python自带的单元测试框架,有时候又被称为”PyUnit”,是python ...
- 测试教程网.unittest教程.8. 断言异常
From: http://www.testclass.net/pyunit/assert_raise/ 背景 我们有时候需要断言一些方法会抛出异常,这些异常需要符合我们的预期. 代码 新建test_e ...
- 测试教程网.unittest教程.7. 各种断言方法
From: http://www.testclass.net/pyunit/assert/ 背景 unittest支持各种断言方法. 断言列表 官方文档 方法 检查点 assertEqual(a, b ...
- React.js 官网入门教程 分离文件 操作无法正常显示HelloWord
对着React官网的教程练习操作,在做到分离文件练习时,按照官网步骤来却怎么也无法正常显示HelloWord. 经测试,html文件中内容改为: <!DOCTYPE html><ht ...
- 前端测试框架Jest系列教程 -- 简介
写在前面: 随着互联网日新月异的发展,用户对于页面的美观度,流畅度以及各方面的体验有了更高的要求,我们的网页不再是简单的承载文字,图片等简单的信息传递给用户,我们需要的是更加美观的页面展示,更快的浏览 ...
随机推荐
- input标签(单选框和复选框)
单选框: <form> <input type="radio" name="..." value="..." checke ...
- Gym.101955: Asia Shenyang Regional Contest(寒假自训第10场)
C.Insertion Sort 题意:Q次询问,每次给出N,M,Mod,问你有多少种排列,满足前面M个数字排序之后整个序列的LIS>=N-1. 思路:我们把数字看成[1,M],[N-M+1,N ...
- lesson3-神经序列模型I-小象
优化目标函数: batch gradient descent:必须便利all训练数据 -->随机梯度下降,但不稳定~一个数据点就更新,快但不稳定-->minibatch,取m个随机数据点, ...
- tomcat服务器安装方法
tomcat: 链接:https://pan.baidu.com/s/1pMEu0hP 密码:g0ah (tomcat7) jdk :链接:https://pan.baidu.com/s/1 ...
- 51Nod 1070:Bash游戏 V4(斐波那契博弈)
1070 Bash游戏 V4 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 有一堆石子共有N个.A B两个人轮流拿,A先拿.每次拿的数量最少1个 ...
- 栈与队列(Stack and Queue)
1.定义 栈:后进先出(LIFO-last in first out):最后插入的元素最先出来. 队列:先进先出(FIFO-first in first out):最先插入的元素最先出来. 2.用数组 ...
- C++学习(三十)(C语言部分)之 栈和队列
数据结构1.保存数据 2.处理数据数组+操作增查删改 栈和队列是一种操作受限的线性表 栈 是先进后出 是在一端进行插入删除的操作--->栈顶 另一端叫做栈底(栈和栈区是两个概念)(是一种数据结构 ...
- hdu3336 Count the string 扩展KMP
It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...
- hdu1542 Atlantis 线段树--扫描线求面积并
There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some ...
- LeetCode - Number of Distinct Islands
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...