开始在Flutter中自动进行用户测试

How you can build test cases from zero and why testing is important.

如何从零开始构建测试用例,以及为什么测试很重要。

Testing an app is very important. We all have heard stories about how great products caused a terrible loss for some undetected errors. To minimize that type of risk, testing software is a very common (and really good) practice. From unit testing to integration testing, there are a lot of methods to check if our app or system is working as expected. But even with that, every software always has undetected defects: Errors and bugs only discovered by the final user. We don’t want the user to get a bad experience with our product so… Can we try to minimize the number of errors? Or in other words: Can we detect the most number of bugs before we release our system?

测试应用程序非常重要。 我们都听说过有关优质产品如何导致一些未发现的错误的巨大损失的故事 。 为了最大程度地减少这种风险,测试软件是一种非常普遍的做法(也是非常好的做法)。 从单元测试到集成测试,有很多方法可以检查我们的应用程序或系统是否按预期运行。 但是即使这样,每个软件也始终存在无法检测到的缺陷:错误和错误只有最终用户才能发现。 我们不希望用户对我们的产品有不好的体验,所以……我们可以尝试减少错误数量吗? 或者换句话说:在发布系统之前,我们能否检测到最多的错误?

One way to do that is by working with testers. They will run our app once and again to discover hidden bugs, mimicking the expected (and the unexpected) user’s behavior. This is a really great method, and with more testers more chance to get bugs discovered. But we don’t have always the necessary resources to work with them: It’s necessary to find alternative methods to try to mimic the user’s behavior.

一种方法是与测试人员合作 。 他们将一次又一次地运行我们的应用程序,以发现隐藏的错误,从而模仿预期(和意外)用户的行为。 这是一种非常好的方法,并且有更多的测试人员有更多的机会发现错误。 但是我们并不总是拥有与之合作的必要资源:有必要找到替代方法来尝试模仿用户的行为。

自动化测试 (Automated Testing)

When developing Flutter apps we can create a lot of automated tests: Unit tests to verify the correct response of our functions or methods, integration tests to check the behavior of some parts of our system when working together and widget tests to verify that the widget’s UI looks and interacts as expected. But we can’t really see (at least in the last one) how the app is working, how the widgets are rendered or how they are responding to user interaction. As the Flutter team say in the Flutter Test page:

在开发Flutter应用程序时,我们可以创建许多自动化测试:单元测试以验证我们的功能或方法的正确响应;集成测试以在共同工作时检查系统某些部分的行为;小部件测试以验证小部件的UI看起来并按照预期进行交互。 但是我们真的看不到(至少在最后一个中)应用程序的工作方式,小部件的呈现方式或它们如何响应用户交互。 正如Flutter小组在Flutter测试页面上所说:

A widget test’s environment is replaced with an implementation much simpler than a full-blown UI system.

与全面的UI系统相比,小部件测试的环境已被实现简单得多的实现所取代。

To overcome this problem and test automatically our apps while watching how every widget or interface is reacting, we can get the help of some open source packages. So today, I am going to introduce one of them: The automated_testing_framework package.

为了克服这个问题并在观察每个小部件或界面的React时自动测试我们的应用程序,我们可以获得一些开源软件包的帮助。 因此,今天,我将介绍其中之一: automatic_testing_framework软件包。

构建可测试的应用 (Building a testable app)

导入必要的组件: (Importing the necessary components :)

This time we are going to test the most simple Flutter app: The CounterApp. To do so we create a new Flutter project:

这次,我们将测试最简单的Flutter应用: CounterApp 。 为此,我们创建一个新的Flutter项目:

flutter create new_app

After that

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值