-
-
Notifications
You must be signed in to change notification settings - Fork 501
Change tests in ArrayList using Reflection API #52
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 overall looks good! 👍
Please address comments and don't forget to extract try-catch
blocks from all tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 it's not safe to get this object by name since people can use other names for this field. That's why you should find array type filed, as I did in PoC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 test should not contain these try-catch
blocks. Please create a helper method setTestSize(size)
and move this logic to that method. You can also mark that method with @SneakyThrows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 this logic looks like a good candidate for a test method:
@SneakyThrows private void fillTestArray(Object... elements){ getFieldByName("elementData").set(arrayList, elements); getFieldByName("size").set(arrayList, elements.length); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 let's rename this method to createListWithSpecificArrayCapacity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 this logic is redundant, we just need to verify that array capacity equals the one we passed to the constructor. So please remove this logic as well as assertions, verify that the inner array length is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 let's rename this test method to setElementByIndexThrowsExceptionWhenIndexIsOutOfBound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 let's remant test method to removeElementByIndexThrowsExceptionWhenIndexEqualsSize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 please remove this last assertsion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 please rename to removeElementByIndexThrowsExceptionWhenIndexIsOutOfBounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erneman1 please remove all unnecessary blank lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a new testing logic we can change our test ordering to a logical and natural sequence of the exercise performing. For instance performing all the "add" test firstly.
No description provided.