This might seem like a stupid question but I find myself facing this problem fairly often.
I want to write an simple application that monitors when a type on the keyboard and when I use the mouse so that I can monitor my computer usage and productivity.
Consider the following gherkin feature:
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
To my mind this does not seem testable.
So what should I do?
Should I resolve this using a layer of abstraction by writing a separate component that monitors mouse movement and then have that report to a user interaction module and mock the mouse movement component?
How does one deal with untestable code like the above?
I would really appreciate any advice you could offer on this.
The answer is usually to just think about the problem in a different way.
For example, I think the specific feature you have mentioned is actually quite testable as it is possible to move the mouse in code, and you should probably be able to fire click events, too. You'd have to get quite specific in the actual scenarios:
... etc.