test timed out after 250 milliseconds

James Bond asked 2 months ago

test timed out after 250 milliseconds

Why is this happening? It works fine in eclipse

5 Answers

Best Answer

Ryan Staff answered 2 months ago

ClassCube problems have a couple of time limits when they run to keep code from taking over the servers. By default each individual test has 250 milliseconds to run, altough whoever creates the problem can bump that up to a point.

What you’re seeing is a loop that’s taking too long. Usual cause is an infinite loop, although if you’re running it successfully in Eclipse that’s probably not the case. Another possibility is there’s just too much data.

Is this a problem your teacher assigned? Best bet would be to get with them to look over your code.

James Bond answered 2 months ago

org.junit.runners.model.TestTimedOutException: test timed out after 250 milliseconds

James Bond answered 2 months ago

I am about to just hardcode the expected result. Is this because of it being too complex? Too many clases? I do use a while loop but it shouldnt be because of that because I use the while loop to handle multiple commands in scanner. Is scanner the reason for the timeout because it is yielding the code until I input?

James Bond answered 2 months ago

Im back, I commented the while loop and it runs now at least but I need this loop in order to make the amount of commands to be user decided. There is a STOP command to stop the loop and there are other commands. Please help fix this.

James Bond answered 2 months ago

Hi Ryan,
Yes I used an infinite loop but in the loop I used scanner for user input but I would think that the test case auto inputs this scanner input. The problem I think I have found is the teacher said it used STOP command but the actual test input never included STOP as a command which may be why it stopped. I will ask and see if this is true.

Your Answer