当前位置:网站首页>单元集成(接⼝)测试
单元集成(接⼝)测试
2022-07-27 05:22:00 【小小代码搬用工】
⽩盒测试是利⽤程序内部的逻辑结构及有关信
息,设计或选择测试⽤例。
⽩盒测试也称结构测试或逻辑驱动测试,是针对被测单元内部是如何进⾏⼯作的测试。它根据程序的控制结构设计测试⽤例。
⽩盒测试主要⽤例设计⽅法
1.基本路径测试方法:把所有路径都覆盖到。
2.逻辑覆盖法:把所有逻辑关系(与或非),控制结构(循环,分支,顺序)
逻辑覆盖法
import math
def Do_Work(x, y, z):
k = 0
j = 0
if (x > 3) and (z < 10):
k = x * y - 1
j = math.sqrt(k) # 语句⼀
if (x == 4) or (y > 5):
k = x * y + 10
j = math.log10(k) # 语句⼆
j = j % 3 # 语句三
return j
from unittest import TestCase
import sqrk_work
from ddt import ddt,data,file_data
import unittest
import sys
from HTMLTestRunner import HTMLTestRunner
# sys.path.append("D:\pycharm test","D:\pycharm test\ceshi")
@ddt
class TestDo_work(TestCase):
@data([4,6,9,1],[2,6,8,0],[5,3,7,0],[1,3,11,0])
def test_Do_work(self,value):
assert value[3]==sqrk_work.Do_work(value[0],value[1],value[2])
if __name__ == '__main__':
#是一个测试用例的合集,就是把要测试用例放到这里
suite = unittest.TestSuite()
#在套件中添加测试用例(通过loader方式+测试用例名+class名)
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestDo_work))
#在套件中添加测试用例(通过loader方式+测试用例名+class名.方法名)
# suite.addTests(unittest.TestLoader().loadTestsFromName('test_add_data'))
#建立一个文件把运行后的结果定入到文件中(html)-text默认
with open('result.html','wb')as file:
#把文件写在运行器中
runner = HTMLTestRunner(stream=file,title='测试报告',description='测试实例')
#运行套件
runner.run(suite)
def test(s):
english = 0
num = 0
qita = 0
space=0
for x in s:
if x.isalpha():
english+=1
elif x.isdigit():
num+=1
elif x==' ':
space+=1
else:
qita+=1
return english,num,space,qita
print(test(input("qingshuru:")))

边栏推荐
猜你喜欢

Unity shader overview

wireshark数据包修改--添加或修改消息字段(二)

如何选择正确的服务器备份方法

Advanced ROS communication mechanism

Chapter for software testing

C language minesweeping latest recursive expansion super detailed explanation (with source code)

ROS topic name setting

Index and transaction of database (emphasis)

Robot navigation implementation

What is the difference between single line and three line when renting servers in Hong Kong?
随机推荐
wireshark数据包修改--添加或修改消息字段(二)
IP核之RAM
Unity Hub登录无响应
C language minesweeping latest recursive expansion super detailed explanation (with source code)
Sexy prime number (acwing daily question)
接口测试概念及Postman工具简介使用
Dynamic planning for solving problems (6)
The principle of hash table and the solution of hash conflict
Solve binary tree (5)
Some descriptions and usage of database index
5g's past and present life -- a brief introduction to the development of mobile communication
切线空间以及TBN矩阵
Multi coordinate transformation
Navigation related messages
ROS运行管理之launch文件
Unity engine starts to migrate from mono to.Net coreclr
多线程的相关知识
数据库在终端的增删改查
UnityShader-LowPoly
socket 长链接