Timeline for How to do unit tests on a method that takes the elapsed time into account?
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 13, 2013 at 9:12 | vote | accept | mhr | ||
| Feb 13, 2013 at 9:11 | comment | added | Kilian Foth | Then refactor it and replace every call to System.currentTimeMillis() with a method Time.now(), which usually does the same, but in test can be made to return any value you like. This can take some effort, but it's not likely to break anything, since it's a very focused and contained change. | |
| Feb 13, 2013 at 9:09 | comment | added | mhr | The time is indeed obtained via the System. The function method stores the loginTime and calculates elapsedTime via DateTime.Now - loginTime. I'll try to mock that into. Thanks for pointing me in that direction. | |
| Feb 13, 2013 at 9:03 | history | answered | Kilian Foth | CC BY-SA 3.0 |