Issue
I'm trying to use the timeout parameter for Annotation Type Test in a unit test within an IntelliJ IDEA project:
The second optional parameter, timeout, causes a test to fail if it takes longer than a specified amount of clock time (measured in milliseconds). The following test fails:
@Test(timeout=100) public void infinity() { while(true); }
--- from http://junit.sourceforge.net/javadoc/org/junit/Test.html
When I try to use this, I get a “Cannot resolve method ‘timeout’” error from IDEA. I'm using Version 4.8.2 of JUnit and version 10.5 of IDEA.
Any idea what I'm doing wrong here?
Solution
Most likely you have multiple junit.jar versions in your project classpath, the old one without this annotation method support is loaded first and you get the error. Make sure that you have only one junit.jar instance in the classpath and that it is the latest version (try the one bundled with IDEA).
Answered By - CrazyCoder
Answer Checked By - David Goodson (JavaFixing Volunteer)