创建测试用例可执行文件 - 免费 RTOS

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

创建测试用例可执行文件

测试用例可执行文件包含要运行的测试逻辑。一个测试套件可以包含多个测试用例可执行文件。在本教程中,您将只创建一个测试用例可执行文件。

  1. 创建测试套件文件。

    MyTestSuite_1.0.0/suite/myTestGroup/myTestCase 文件夹中,创建使用以下内容的 myTestCase.py 文件:

    from idt_client import * def main(): # Use the client SDK to communicate with IDT client = Client() if __name__ == "__main__": main()
  2. 使用客户端SDK函数将以下测试逻辑添加到您的myTestCase.py文件中:

    1. 在被测设备上运行SSH命令。

      from idt_client import * def main(): # Use the client SDK to communicate with IDT client = Client() # Create an execute on device request exec_req = ExecuteOnDeviceRequest(ExecuteOnDeviceCommand("echo 'hello world'")) # Run the command exec_resp = client.execute_on_device(exec_req) # Print the standard output print(exec_resp.stdout) if __name__ == "__main__": main()
    2. 将测试结果发送到IDT。

      from idt_client import * def main(): # Use the client SDK to communicate with IDT client = Client() # Create an execute on device request exec_req = ExecuteOnDeviceRequest(ExecuteOnDeviceCommand("echo 'hello world'")) # Run the command exec_resp = client.execute_on_device(exec_req) # Print the standard output print(exec_resp.stdout) # Create a send result request sr_req = SendResultRequest(TestResult(passed=True)) # Send the result client.send_result(sr_req) if __name__ == "__main__": main()