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

Replace usages of @Test(expected) with Assert.assertThrows(). #1579

Merged
merged 1 commit into from
May 18, 2024

Conversation

motlin
Copy link
Contributor

@motlin motlin commented May 17, 2024

Relates to #1578 and #1576. It turns out that just moving away from JUnit 4 syntax for expected exceptions is a fairly large change on its own. @Desislav-Petrov please take a look.

@motlin motlin requested a review from donraab May 17, 2024 17:35
iterator.next();
}
assertThrows(NoSuchElementException.class, () -> iterator.next());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These overrides don't make sense - I'll remove them. The test is for non-empty-collection, and this overrides it to only make assertions about empty collections.

Copy link
Contributor

@donraab donraab left a comment

Choose a reason for hiding this comment

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

One suggested change inline in regards to missing static import.

public void get_throws_index_greater_than_size()
{
this.classUnderTest().get(this.classUnderTest().size());
Assert.assertThrows(IndexOutOfBoundsException.class, () -> this.classUnderTest().get(this.classUnderTest().size()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you not want to make this a static import since you are changing this anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sure, it was like that in the original but I'll change it.

}
iterator.next();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test is almost identical to the superclass, but it uses add() instead of a varargs creation method. Calling add() is the reason it doesn't work in unmodifiable tests which results in even more overrides.

Copy link
Contributor

@donraab donraab left a comment

Choose a reason for hiding this comment

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

LGTM

@donraab donraab merged commit e6ad9ec into eclipse-collections:master May 18, 2024
16 checks passed
@motlin motlin deleted the test-expected-exception branch May 18, 2024 12:21
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.

3 participants