如何测试我是否收到通知

发布于 2025-01-11 15:47:51 字数 1432 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-01-18 15:47:51

有几种方法

  1. 通过检查潜在调用的效果来验证它是否已被调用 - 例如,某些对象确实改变了其状态,并且它是可验证的
  2. 监视应该调用方法的实例 - 然后您可以检查该方法是否已被调用直接调用
  3. 使用可观察模式并将“观察”行为添加到测试用例中。

可能更多。

Couple of ways

  1. Verify it has been called by checking the effects of potential call - eg some object did change its state as a result and it is verifiable
  2. Spy on instance that is supposed to have method called - you can then check if the method have been called directly
  3. Use observable pattern and add 'observe' behavior to the test case.

probably much more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文