|
Post by account_disabled on Apr 4, 2024 4:46:58 GMT
让我们回到预订示例假设这次我们正在使用编译为文件的版本。然后您需要做两件事启用预订等待预订准备好接受请求。通过使用部署系统时使用的现有代码或脚本可以非常轻松地处理第一步。这可以像在命令行上运行文件一样简单或者使用等工具来运行包含我们的的映像这超出了本书的范围。更棘手的部分是确保我们的自动化在可以接受请求之前不会运行否则检查将会出现误报。最有可能的是您必须找到一个现成的工具或者编写将阻塞管道一段时间的代码直到准备就绪。 有很多方法可以解决这个问题。例如您可以创建一个实用程序该实用程序将成为管道的一部分例如我在中为平台创建的监 阿曼数据 视器应用程序。或者您可以通过添加检查来扩展自动化框架以确保已准备好接受请求如可以添加到的处理程序中所示无法连接到尝试响应给定超时限制线程睡眠否则中断异常线程睡眠方法接受和参数用于将请求发送到选定的端点。如果请求包含状态代码则该方法会计算并等待一秒钟然后重新发送请求。该方法可能会以以下两种方式之一失败达到并引发失败消息指示出现问题。 答案打破了循环这意味着自动检查可以开始。我们可以在处理程序中调用该方法处理程序现在将检查预订是否每秒运行一次持续秒。如果此时尚未运行检查将失败并显示一条消息不可用。值得重复的是这只是使用工具和或库来运行的众多方法之一。主要结论任何无法激活本身的测试自动化系统都应该提供类似的东西。这种方法对某些人来说可能看起来不方便因为它创建了更多的代码来维护和新的潜在错误源。这就是为什么有时值得退后一步看看我们是否可以对上下文进行更改以调整生产和测试自动化代码。
|
|