最简明的冒烟测试

简介

一.冒烟测试

冒烟测试是在软件开发过程中的一种针对软件版本包的快速基本功能验证策略,是对软件基本功能进行确认验证的手段,并非对软件版本包的深入测试。冒烟测试也是针对软件版本包进行详细测试之前的预测试,执行冒烟测试的主要目的是快速验证软件基本功能是否有缺陷。

二.用例

1.unittest用例

import unittest

class TestSmoke(unittest.TestCase):

	def test1(self):
		print('测试1')
		
	def test2(self):
		print('测试2')
	

	def aa(self):
		print('ok')
	

运行

if __name__ =='__main__':
	unittest.main()

使用TestSuit套件

import unittest

class TestSmoke(unittest.TestCase):

	def test1(self):
		print('测试1')
		
	def test2(self):
		print('测试2')
	

	def aa(self):
		print('ok')
	

运行

if __name__ =='__main__':

	testcase = unittest.TestSuit()
	
	testcase.addTest(unittest.TestLoader().loadTestsFromName(['test.TestSmoke.test1']))
	
runn = unittest.TextTestRunner(verbosity = 2)

runn.run(testcase )



#TestSuit   套件

#TestLoader 加载测试用例并将他们包装到套件当中

# TextTestRunner  运行用例



2.基于pytest


import unittest
import pytest

class TestSmoke(unittest.TestCase):
	
	@pytest.mark.smoke	
	def test1(self):
		print('测试1')
		
	@pytest.mark.smoke		
	def test2(self):
		print('测试2')
	

	def aa(self):
		print('ok')
	

运行

在终端执行:

pytest test.py -m smoke

unitTest和pytest区别

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45066628/article/details/111151732