I'm working on a project that displays the possible transfers at the next bus stop for the own vehicle. Each transfer is accompanied by departure time in minutes.
Since the information is dynamic you might have already guessed that it is retrieved from a remote server, which (of course) I have no access to except sending GET requests and parsing the XML replies. Loss of connectivity is handled separately from the topic in this question. The main goal here is to create a dummy web server that will allow the tester to write new test cases and then run those against the application in a more realistic manner without the need to change the code of the tested software.
The onboard unit (the brain of the bus) generates several important pieces of information that are sent to the system that the software is running on - line number, course number and the stop ID the vehicle is headed to.
The stop ID is used as a parameter in a GET request to the remote server, which in return replies with an XML document full with journeys including own journey and both valid and invalid transfers.
After finding the own journey (based on current date, line and course number all of which are part of a unique ID for each journey) all other journeys go through a set of filters one of which calculates the departure time relative to the current system time and checks if the transfer isn't leaving the next bus stop BEFORE the own vehicle has arrived there (transfer time on foot is also included in this calculation).
As you can see there are two places where current time is of the essence (on the server side) and one - on the application side. I'm now in the process of setting up a dummy web server that will allow me to verify some of the features related to the data from the remote server (unit testing).
Normally (if data was not bound to the current system time) I would go straight for the good old "create XML files each covering specific case(s) and then load these one at a time". However due to the dynamic nature of the data and the filter(s) that are in place this approach won't do.
There are currently two solutions that I have come up with so far:
- Given that the XML files I've just mentioned are present before each test run update these (all time-related data inside)
- Generate XML replies on the fly and automatically adjust the time stamps in those - this has one big flaw namely that adding new test cases would involve writing new code
I find the second version more appealing because I would be able to integrate the generation of the XML data more tightly with my test web server.
Is this the better option? Are there other better ones?