0

I am writing some python tests for an embedded system.
I send the device a command to run some feature, while reading result(logs) via serial port.

I would like to compare my expected results to the device output, and check for incorrect behavior of device according to the logs and display the results.

I am looking for a pythonic way to do tests and summarize results. all tests must run even if one failed.

Currently, my code looks something like this :

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
   ...
   ...

I want to use one of the frameworks(unittest, pytest). Which one will fit better so i don't have to rewrite my code too much?

schanti schul
  • 681
  • 3
  • 14
  • Possible duplicate of [Test framework for testing embedded systems in Python](https://stackoverflow.com/questions/34189223/test-framework-for-testing-embedded-systems-in-python) – William Laroche Nov 08 '19 at 14:11

1 Answers1

0

You can use pytest for writing tests.You just need to change the both method name with suffix 'test_' as it is test discovery of pytest.

nikhilesh_koshti
  • 393
  • 1
  • 10