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

forked from #450 and improved #544

Merged
merged 4 commits into from
Nov 15, 2012
Merged

Conversation

Tibor17
Copy link
Contributor

@Tibor17 Tibor17 commented Nov 12, 2012

Unlike in #450 i did not delete Timeout(int) constructor because it is backward compatibility issue (in class bytecode).

Instead Deprecated such one.

Added other two constructors with params:

  • with long
  • long and TimeUnit

improved tests and to truly realistic javadoc.

Compiled and tested with JDK 5.

@marcphilipp
Copy link
Member

For later reference: This pull request addresses #406.

public class FailOnTimeout extends Statement {
private final Statement fOriginalStatement;

private final TimeUnit fTimeUnit;
private final long fTimeout;

public FailOnTimeout(Statement originalStatement, long timeout) {
Copy link
Member

Choose a reason for hiding this comment

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

Now that one can specify a TimeUnit, I think millis would be a clearer parameter name. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, i will update it. thx

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 13, 2012

@marcphilipp
@dharkness
see the latest update

* @param millis the millisecond timeout
* @since 4.11
*/
public Timeout(long millis) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we decided the last time we introduced TimeUnit to a class that the benefit to having three constructors wasn't worth the cognitive load of having to choose which constructor. Let's please not add this constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dsaff
Should be this constructor removed now?
thx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcphilipp
@dsaff
@kcooney
@dharkness

I would be very happy to remove the constructor Timeout(int), but i am worry about what would happen if i do.
So i simulated this scenario, where your tests dependent on 4.10 using Timeout(int) suddenly change the junit version without recompiling them based on junit 4.11.

This will happen:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.rules.Timeout.(I)V

If it's the rule to update the documentation, then we should do it. If not, then i will remove this constructor.

Choose a reason for hiding this comment

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

I think the suggestion was to remove the constructor taking a long value. Keep the original int constructor for compatibility and add only the long + TimeUnit constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dharkness

See #406, which says that casting long to int is an evil due to truncation in numbers.

new Timeout( (int) DateUtils.MILLIS_PER_MINUTE * 5 )

Copy link
Member

Choose a reason for hiding this comment

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

Another option that I like is to have

@Deprecated Timeout(int) {}
Timeout(long, TimeUnit)
static Timeout millis(long millis);
static Timeout seconds(long seconds);
static Timeout minutes(long minutes);

That way there's easy, non-confusable shortcuts for the most common options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dsaff
I can do it now, but then you have two paradigms in one: a factory and typical object creation.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 14, 2012

@dsaff
@marcphilipp
@kcooney
@dharkness

All requests implemented except for factory #minutes() because we do not have TimeUnit.MINUTES in Java 5:

  • deleted 2 examples in Javadoc of Timeout
  • improved Javadoc bottom text
  • improved Javadoc in constructor #Timeout(int)
  • added two factories to Timeout #millis() and #seconds()
  • @SInCE 4.12
  • added test abstraction

* }
* public void run2() {
* //uninterrupted code
* for (;;)
Copy link
Member

Choose a reason for hiding this comment

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

I think the canonical Java infinite loop is

while (true) {}

I think if we name the method infiniteLoop(), and use that style, we can drop the comment-within-a-javadoc below.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2012

@dsaff
updated:

  • cannonical style of infinite loop in Javadoc
  • new Line avoided in abstract test inheritance

@dsaff
Copy link
Member

dsaff commented Nov 15, 2012

Thanks, @Tibor17!

dsaff pushed a commit that referenced this pull request Nov 15, 2012
@dsaff dsaff merged commit c97adf9 into junit-team:master Nov 15, 2012
@dsaff
Copy link
Member

dsaff commented Nov 15, 2012

@Tibor17, can you please add a bullet about this at https://github.com/KentBeck/junit/wiki/4.12-release-notes? Thanks.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2012

@marcphilipp
yes, i will do it.

1 similar comment
@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2012

@marcphilipp
yes, i will do it.

Tibor17 pushed a commit to Tibor17/junit that referenced this pull request Nov 15, 2012
@Tibor17 Tibor17 mentioned this pull request Nov 15, 2012
@marcphilipp
Copy link
Member

@Tibor17 ?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2012

@marcphilipp
I am again connected.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 15, 2012

@marcphilipp
pls check my update of rel notes
https://github.com/KentBeck/junit/wiki/4.12-release-notes

Do you need me to update an *.md file as well?

@marcphilipp
Copy link
Member

@marcphilipp https://github.com/marcphilipp
pls check my update of rel notes
https://github.com/KentBeck/junit/wiki/4.12-release-notes

Looks good, thanks!

Do you need me to update an *.md file as well?

No, we've decided to update the *.md file right before the release.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 16, 2012

ok, thx.

@marcphilipp
@dsaff

Would you take a look at #549 ?
thx.

dsaff pushed a commit that referenced this pull request Dec 12, 2012
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.

5 participants