Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw TestFailedOnTimeoutException instead of plain Exception on timeout. Fixes #771 #777

Closed
wants to merge 14 commits into from

Conversation

askoog
Copy link

@askoog askoog commented Nov 28, 2013

Throw TestFailedOnTimeoutException instead of plain Exception on timeout. Fixes #771

@@ -0,0 +1,11 @@
package org.junit.internal.runners.statements;

public class TestFailedOnTimeoutException extends Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add Javadoc?


private static final long serialVersionUID = 31935685163547539L;

private TimeUnit fTimeUnit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please make these fields final?

@kcooney
Copy link
Member

kcooney commented Nov 30, 2013

Thanks for the changes! A few very minor issues

@dsaff do you have a preference for which package this new exception type should live in, and what it should be named?

evaluateWithWaitDuration(TIMEOUT + 50);
}

private BaseMatcher<TestFailedOnTimeoutException> exceptionWithTimeout(final long timeout, final TimeUnit unit) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a big one-off effort to avoid try/catch in a single class...

@kcooney
Copy link
Member

kcooney commented Dec 24, 2013

@askoog I think the only remaining issues are 1) the name of the class (I'll let @dsaff decide on that) and 2) an apparent build failure. I couldn't see why the build failed, so if you can run the tests via mvn or ant that would be great.

@askoog
Copy link
Author

askoog commented Dec 25, 2013

Changed name of the exception to TestTimedOutException as of suggestion by @dsaff. The build failure was due to unmerged changes for travis ci (#776) and should work by now. mvn clean test also works fine on my machine™

}

/**
* @return the time passed before the test was interrupted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't think you need both a description and a @return it's best to just have a description and omit the @return. The first sentence of the description used in the Javadoc as the short description. So I would replace this line with "Gets the time passed before the test was interrupted"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say I don't agree with you. I think its the other way around. Specify the return statement, it makes it clear what you will receive from the method. No further description indicates that the method doesn't do anything interesting otherwise... Most developers don't use the generated javadoc html page, but the popup in their IDE and there you see the return statement clearly.

But, I will do as you suggest since this is starting to be a long running pull request...

@kcooney
Copy link
Member

kcooney commented Dec 28, 2013

looks good to me. Thanks! Some very minor style notes.

@kcooney
Copy link
Member

kcooney commented Jan 20, 2014

@askoog It won't let me merge. Could you merge from head? Thanks. Feel free to squash to one commit or not as you like.

Conflicts:
	src/test/java/org/junit/tests/AllTests.java
@askoog
Copy link
Author

askoog commented Jan 20, 2014

Tried to merge changes, but I think i screw up something. Seems I committed some files with new line endings(?)... Any good ideas how to fix that?

The merge conflict before was in the AllTests class btw

@kcooney
Copy link
Member

kcooney commented Jan 24, 2014

@askoog I'm guessing your IDE was set to use different line endings. I suggest figuring out how to fix that, going back to the commit before the merge, fixing the line endings, and merging again.

Sorry, I can't pull in a request where it looks like every line has changed

@marcphilipp
Copy link
Member

@askoog We would like to ship this in 4.12. Do you have time to work on it?

@askoog
Copy link
Author

askoog commented Feb 15, 2014

@marcphilipp Is there still a merge problem? Seems I messed up the branch earlier, might be easier to create a new PR from another branch. I'll see what I can do. When is 4.12 due for shipping?

@askoog
Copy link
Author

askoog commented Feb 15, 2014

@marcphilipp @kcooney I've created a new branch without the newline accident. It's in PR #823 #823. Hope that one merges better, the change set looks better anyway. Tell me when it's merged and I will close this PR.

@marcphilipp
Copy link
Member

Closing in favor of #823.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throw TimeoutException when test fails with timeout
6 participants