user4833678
user4833678

Reputation:

Test timed out. When does it happen?

I've been coding and testing it by JUnit on Eclipse, and some of the tests are failing with the error messege: timed out after 1000 milliseconds. Those methods that are failing have O(1) complexity. Im not posting a code, Im just curious that when does this time out error happen? If possible, please in plain words :).

Upvotes: 0

Views: 2748

Answers (1)

Stanislav
Stanislav

Reputation: 28106

Take a look at JUnit timeouts for tests description. In short, you are able to determine not only assertions and expected exceptions for tests, but alse the maximum execution time, which should the test take. It's possible as a parameter for @Test Annotation, but also as a rule for entire test class. It has nothing to do with test complexity, just with the execution time. This means that your falling test are running more then 1000 miliseconds.

As I know, in some environments it's possible to set the default timeout value for all JUnit tests, for example in Ant via some property for the test task. So, you have to take a look at your tests structure, especially if your tests are extending some base test classes and take a closer look at the environment, where you are running this test.

Upvotes: 1

Related Questions