Closed csmengwan closed 11 years ago
My guess is that you're having trouble setting up the RequestParameters object. Is this correct?
If so, I have a suggested solution: Add a public static constructor to the RequestParameters object:
public static final RequestParameters buildParameters(final String startAddress, final String endAddress, final long arrivalTime, final long departureTime, final TravelMode travelMode, final long minDistanceToBikeInMeters, final long maxDistanceToBikeInMeters, final int minNumberBusTransfers, final int maxNumberBusTransfers) { RequestParameters newParameters = new RequestParameters(); newParameters.startAddress = startAddress; newParameters.endAddress = endAddress; newParameters.arrivalTime = arrivalTime; ... newParameters.maxNumberBusTransfers = maxNumberBusTransfers;
return newParameters; }
Now you can instantiate your own RequestParameters object without using a DirectionsRequest object, so you should be able to test the SimpleComboAlgorithm without a DirectionsRequest object and without doRequest(). I like this option because it keeps the previous setup the same (algorithms can't modify RequestParameters objects) but allows for more straightforward testing. Note: because this method has so many parameters, you may want to note in the javadoc comment for it that it is meant primarily for unit testing purposes.
Let me know if you have questions!
I believe this has been fixed. Please reopen if not.
Hi, all. I have an issue writing the algorithm test for the simpleComboAlgorithm. It is called by DirectionRequest. Should I just create a new DirectionRequest and let it call doRequest once I set up all the inside fields?