-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
Milestone
Description
Nils Wloka opened SPR-6011 and commented
Given the following component:
@Component
public class VerySlowKnowledgeBase implements KnowlegdeBase {
public Iterable<Answer> findAnswersFor(Topic topic) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// Nothing to do here
}
return null;
}
}
the following test fails as expected:
@Test
@Timed(millis = 100)
public void popular_queries_should_yield_results_within_100_millis() {
Topic topic = new SearchPhraseBasedTopic("Declarative Caching with Spring");
Iterable<Answer> result = knowledgeBase.findAnswersFor(topic);
}
whereas this test passed even though it takes more than a second to do so:
@Repeat(10)
@Test
@Timed(millis = 1000)
public void popular_queries_should_yield_results_within_100_millis() {
Topic topic = new SearchPhraseBasedTopic("Declarative Caching with Spring");
Iterable<Answer> result = knowledgeBase.findAnswersFor(topic);
}
Also,
@Test
@Timed(millis = 400)
@Repeat(4)
public void popular_queries_should_yield_results_within_100_millis() {
Topic topic = new SearchPhraseBasedTopic("Declarative Caching with Spring");
Iterable<Answer> result = knowledgeBase.findAnswersFor(topic);
}
leads to
INFO: Repetition 1 of test SelectByTopicTest#popular_queries_should_yield_results_within_100_millis()
...
java.util.concurrent.TimeoutException: Test took 501 ms; limit was 400 ms.
which indicates that @Timed doesn't measure total execution time (as stated in the reference documentation).
Affects: 3.0 M3, 3.0 M4