Skip to content

@Timed seems not to measure total time when used with @Repeat [SPR-6011] #10680

@spring-projects-issues

Description

@spring-projects-issues

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

Referenced from: commits a45d1de, 9845047

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions