Expectations are matched in reverse order so if last is matched then
the exceptation is fulfulled otherwise it is interpreted as a call to
this stubbed definition.
Is that clear ?
Robert Pankowecki
- Duncan
> --
> You received this message because you are subscribed to the Google Groups
> "mocha-developer" group.
> To post to this group, send email to mocha-d...@googlegroups.com.
> To unsubscribe from this group, send email to
> mocha-develop...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mocha-developer?hl=en.
>
>
It looks like you're doing a lot of sort of setting the Window up and
letting the game run without really decoupling the behavior of the
Player from her rendering.
With this kind of setup, you'll have to simulate batting the ball back
and forth in order to test scoring when batting the ball back and
forth isn't really what's under test.
In Gosu, the Window object does a lot of stuff, so you might consider
picking apart its functionality and injecting pieces into your player
class to drive those parts of your system.
For example, the Window object defines some rendering calls and
drawing bounds. It also takes care of updating the system during
ticks. It also handles user input. Each of these systems can be broken
out from Window and act as an intermediary between the Player and the
real Gosu Window object. This way you can test the interaction of your
player with regards to key-presses independently of how the Player is
rendered.
Hope this makes sense, and good luck.
- Duncan
These tests look pretty byzantine to me, and don't seem to really
afford much wiggle room in how player movement is implemented.
Tests are supposed to help you insure that your code works as you
expect while maintaining flexibility in its implementation, or even in
functionality.
For example, if you were to introduce an easing function into your
acceleration / deceleration the tests would be pretty difficult to
modify, and they definitely don't' seem to offer a clear path forward
should you decide to make this change test-first.
Perhaps the tests can be made more granular: When velocity is X,
pressing the Down button increases it by the result of this easing
function. When velocity is MAX, pressing the Down button does nothing.
It just feels like you're testing a potentially large number of
interactions in each test case (one assertion per test?) Which is
tenable in the early phases of a project, but could quickly lead to
brittle, hard-to-maintain tests down the road.
Please do correct me if you find this turns out otherwise.
- Duncan