建立測試案例可執行檔 - 免費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()