用python测试嵌入式系统

2024-05-26 20:46:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为一个嵌入式系统编写一些python测试。
我向设备发送一个命令来运行某些功能,同时通过串行端口读取结果(日志)。在

我想将我的预期结果与设备输出进行比较,并根据日志检查设备的错误行为并显示结果。在

我正在寻找一种Python式的方法来做测试并总结结果。 即使一个测试失败,也必须运行所有测试。在

目前,我的代码如下所示:

class TestSpecificDeviceFeature() :
    def __init__(self):
        self.expectedResults = AllExpectedResultsForRun()
        sendCommandtoDevicetoRunFeature()
        self.deviceResult = RunDeviceAndCollectOuput()

   def test1():
        print self.expectedResults.result1 ==  self.deviceResult.output1

   def test2():
        print self.expectedResults.result2 ==  self.deviceResult.output2
   ...
   ...

我想使用其中一个框架(unittest,pytest)。 哪一个更适合这样我就不必重写太多代码了?在


Tags: 方法端口代码命令self功能init系统
1条回答
网友
1楼 · 发布于 2024-05-26 20:46:05

可以使用pytest进行编写测试。你只需将两个方法名都改为后缀“test”,因为这是pytest的测试发现。在

相关问题 更多 >

    热门问题