Friday, August 22, 2008

Skip execution of method in specific time of day

/* this test fails if the current time is between 12:00am and 3:00am*/

Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY);
String timeCheck = "Current time not between 12:00am and 3:00am";
String timeDescription = "Current time" + ((hour < 3) ? "" : " not") + " between 12:00am and 3:00am";
Assume.assumeThat(timeDescription, equalTo(timeCheck));

Assume is package org.junit;(public class Assume )

No comments: