File tree 2 files changed +281
-16
lines changed
src/main/java/com/statemachinesystems/mockclock
2 files changed +281
-16
lines changed Original file line number Diff line number Diff line change 1
1
Java 8's ` Clock ` class is a big step in the right direction for testability, but it's still a pain. You can
2
2
test using ` Clock.fixed() ` but that's immutable so you can't test how your code responds to the passage of time.
3
- You can use a mocking library to stub the ` instant() ` method , but that's still awkward and indirect.
3
+ You can use a mocking library to stub the ` instant() ` and ` getZone() ` methods , but that's still awkward and indirect.
4
4
5
5
This library provides a mutable ` MockClock ` class that can be constructed as of a given date and time, then adjusted as
6
6
needed. Here's an example of how to use it:
@@ -17,3 +17,5 @@ needed. Here's an example of how to use it:
17
17
clock.advanceBySeconds(30);
18
18
19
19
assertThat(testSubject.someMethod(), is(expectedValueAfter30Seconds));
20
+
21
+ © ; 2015 State Machine Systems Ltd. [ Apache Licence, Version 2.0] ( http://www.apache.org/licenses/LICENSE-2.0 )
You can’t perform that action at this time.
0 commit comments