Skip to content

Instantly share code, notes, and snippets.

@winder
Last active November 3, 2017 18:53
Show Gist options
  • Save winder/c636c02651485431b7989f23573428b4 to your computer and use it in GitHub Desktop.
Save winder/c636c02651485431b7989f23573428b4 to your computer and use it in GitHub Desktop.
TestFactory Example
@TestFactory
public Stream<DynamicTest> dynamicNextTrackMetricsWeeklyTests() {
final DateTime now = DateTime.now();
int thisMonthLength = YearMonth.now().lengthOfMonth();
// Week 2-4, track weekly
return IntStream.rangeClosed(7, thisMonthLength)
.boxed()
.map(i -> {
Date published = now.minusDays(i).toDate();
Date nextWeek = now.plusWeeks(1).toDate();
return dynamicTest("week < age (" + i + ") < month, track next week.",
() -> testNextMetrics(published, now.toDate(), nextWeek));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment