4 ms·
The issue doesn't generalize across languages because they often have other mechanisms that are simpler. In dynamic languages with modules like Javascript, Rub
by nostrademons 3y ago
The issue doesn't generalize across languages because they often have other mechanisms that are simpler. In dynamic languages with modules like Javascript, Ruby, or Python, you can usually monkey-patch the system time methods to return what you want. In Java and other JVM languages you'd use dependency injection and then inject a mock into the test. Most other languages use some variant of Approach 1 or Approach 5.