我有以下课程:
import java.sql.Timestamp;
public class TimeUtil {
public static Timestamp getTimestamp() {
java.util.Date currentTime = new java.util.Date();
return new Timestamp(currentTime.getTime());
}
}
并在Junit类之后编码:
public class TimeUtilTest {
@Test
public void getTimestamp() {
java.util.Date expected = new java.util.Date();
Timestamp s = TimeUtil.getTimestamp();
assertTrue("not in the expected
timeinterval",Math.abs(expected.getTime() - s.getTime()) < 20L);
}
}
我的目标是通过该测试实现100%的线路覆盖率,但目前仅涵盖66%的线路。有没有人知道如何最大化线路覆盖范围?