首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Specflow测试

Specflow测试
EN

Stack Overflow用户
提问于 2015-06-11 14:17:35
回答 1查看 67关注 0票数 0

这可能看起来是一个愚蠢的问题,但我发现自己经常遇到这个问题。

我想写一个简单的应用程序来监控键盘上的输入和我使用鼠标的时间,这样我就可以监控我的计算机的使用情况和工作效率。

考虑以下小黄瓜功能:

代码语言:javascript
复制
Feature: MouseInteractionMonitoring
    In order to know when the user is at the computer
    As an interaction monitor
    I want to be able to be able to monitor when the user moves the mouse

在我看来,这似乎是不可测试的。

那么我该怎么做呢?

我是否应该使用抽象层来解决这个问题,方法是编写一个单独的组件来监视鼠标移动,然后将该报告发送给用户交互模块并模拟鼠标移动组件?

如何处理像上面这样的不可测试的代码?

我真的很感谢你在这方面能提供的任何建议。

EN

回答 1

Stack Overflow用户

发布于 2015-06-11 15:24:27

答案通常是以不同的方式思考问题。

例如,我认为您提到的特定功能实际上是非常可测试的,因为可以在代码中移动鼠标,并且您也应该能够触发单击事件。在实际场景中,您必须获得非常具体的内容:

代码语言:javascript
复制
Scenario Outline: Should log mouse movements
Given the computer is <status>
When the mouse moves by more than two pixels
Then a mouse move user interaction is logged
  Examples:
  | status |
  | idle   |
  | active |

Scenario: should log left-mouse clicks
When the mouse is left-clicked
Then a left-click user interaction is logged

..。等。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30773041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档