用焦点流程进行左移的iOS测试
Creating a great modern-day software product requires a shift-left approach to testing by ensuring faster, more frequent, and earlier testing. Shift-left testing is an approach to software testing and system testing in which testing is performed earlier in the lifecycle (i.e., moved left on the project timeline). The current standard of automated mobile testing is less effective in implementing the shift-left approach due to some inherent challenges such as time and flakiness of test executions.
创建一个伟大的现代软件产品,需要通过确保更快、更频繁和更早的测试来实现左移的测试方法。左移测试是一种软件测试和系统测试的方法,在生命周期的早期进行测试(即在项目时间线上左移)。由于一些固有的挑战,如测试执行的时间和浮动性,目前的自动化移动测试标准在实施左移的方法方面不太有效。
Most automated tests complete some irrelevant steps in order to reach the application state where the real assertions happen. Let’s explore an example of testing the Lyft Pass details screen of the Lyft Rider app. The test sequence is as follows:
大多数自动化测试完成一些无关紧要的步骤,以达到真正发生断言的应用状态。让我们探讨一个测试Lyft Rider应用的Lyft Pass详情屏幕的例子。测试顺序如下。
- Log in
- 登录
- Tap the hamburger menu
- 点选汉堡包菜单
- Tap payment
- 点选支付
- Select a Lyft Pass
- 选择一个Lyft通行证
- Verify behavior on the Lyft Pass details page
- 在Lyft通行证详情页上验证行为
In the above example, the test controller must execute all the pre-conditional steps before finally testing the Lyft Pass details screen, even if they are of little to no relevance. These pre-conditional UI steps increase the time of execution and its flakiness. If the test fails, there is a high probability that the cause of failure is something other than what the test is verifying.
在上面的例子中,测试控制器必须在最后测试Lyft Pass详情屏幕之前执行所有的预设条件步骤,即使它们几乎没有任何关联性。这些预设条件的UI步骤增加了执行的时间和它的飘忽性。如果测试失败,失败的原因很有可能是测试所验证的内容之外的东西。
One way to address these issues would be to remove the pre-conditional UI steps and focus only on the flow that the test cares about. Removing the pre-conditional steps would allow the tests to execute in less time compared to when executing the full test flow. It would also bring down the flakiness because the test would no longer be impacted by these steps, and the failure would be limited to the actual assertion of ...