Hi!
Your issue is that you are not in control of time and therefore can't
be sure what to expect when you execute the call.
This leads me to think that verifying the message, using Cucumber
instead of a unit test, should be done under the hood and not through
an API call. It is interesting for the business that the correct
message is returned so they might want to see the Gherkin executed.
But in order to be sure that you get the correct message back, you
need to specify the current time for the system under test.
If it is important that the API call is verified, I would complement
the verification above with a verification that sees a message and
don't care about which message. This would verify that the system is
able to answer something that is correct. I.e. the wiring of the
application is OK.
If it isn't possible to do the verification as above, a combination of
white and black box, you need a way to take control over time before
the API call through an endpoint. I would not be happy with it since
that would have to change the time for the entire application. You
can't be sure that your actual API call will be served with the same
thread or similar that you just set the time for.
I guess this is one of those cases where automated black box testing
is complicated due to circumstances you are not in control over. Time
passes and we can't be sure what time an execution will take place.
A twist that Andrews response triggered for me is to force the caller
to supply it's local time. This would solve the problem with users in
different timezones and not rely on server time. It would also
magically solve your problem since you are delegating the
responsibility of handling time to the caller.
Cheers,
Thomas
--
Thomas Sundberg
M. Sc. in Computer Science
Mobile:
+46 70 767 33 15
Blog:
http://www.thinkcode.se/blog
Twitter: @thomassundberg
Better software through faster feedback