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

Set private the lists fEmpty, fFull and remove unnecessary boxing on ListTest #1389

Conversation

AxelMonroyX
Copy link
Contributor

@AxelMonroyX AxelMonroyX commented Nov 21, 2016

Description of change
  • Change from protected to private fEmpty and fFull lists, because there is no need to keep accessible from the package and subclass
  • Remove unnecessary boxing on fFull.remove() because Java creates an Integer object from i and adds to the object fFull
Requested Changes
  • Remove main method from ListTest.java
  • Rename fEmpty to emptyList
  • Rename fFull to fullList
  • Remove extra blank line
  • Change assertTrue() for assertEquals() on testElementAt() method
Checklist
  • Run mvn verify
  • All tests are passing
References:

Controlling Access to Members of a Class
Autoboxing and Unboxing

Change from protected to private fEmpty and fFull
Remove unnecesary boxing on fFull.remove()
@@ -11,8 +11,9 @@
* A sample test case, testing {@link java.util.ArrayList}.
*/
public class ListTest extends TestCase {
protected List<Integer> fEmpty;
protected List<Integer> fFull;
private List<Integer> fEmpty;
Copy link
Member

Choose a reason for hiding this comment

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

While you are changing this, could you please rename "fEmpty" to "empty" or "emptyList"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to be more clear about the samples, on my way to do the changes

protected List<Integer> fFull;
private List<Integer> fEmpty;

private List<Integer> fFull;

public static void main(String[] args) {
Copy link
Member

Choose a reason for hiding this comment

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

While you are changing this file, please remove the main method.

@AxelMonroyX
Copy link
Contributor Author

@kcooney Ready

Requested Changes
  • Remove main method from ListTest.java
  • Rename fEmpty to emptyList
  • Rename fFull to fullList
Checklist
  • Run mvn verify
  • All tests are passing

Copy link
Member

@kcooney kcooney left a comment

Choose a reason for hiding this comment

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

Thanks!

}

public void testElementAt() {
int i = fFull.get(0);
int i = fullList.get(0);
assertTrue(i == 1);
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should use assertEquals() (with as useful message) instead of assertTrue() so you'll get a useful stack trace if this fails? Future users might look at this file as an example of how to write a good JUnit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes is more readable 👍

protected List<Integer> fEmpty;
protected List<Integer> fFull;
private List<Integer> emptyList;

Copy link
Member

Choose a reason for hiding this comment

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

Why the extra blank line?

protected List<Integer> fFull;
private List<Integer> emptyList;

private List<Integer> fullList;
Copy link
Member

Choose a reason for hiding this comment

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

style-nit: remove extra blank line after this declaration.

@AxelMonroyX
Copy link
Contributor Author

@kcooney Ready 👍

Requested Changes
  • Remove extra blank line
  • Change assertTrue() for assertEquals() on testElementAt() method
Checklist
  • Run mvn verify
  • All tests are passing

@kcooney kcooney merged commit a068272 into junit-team:master Nov 22, 2016
sebasjm pushed a commit to sebasjm/junit4 that referenced this pull request Mar 11, 2018
* Set private to fEmpty, fFull and remove unnecesary boxing on ListTest
* Change from protected to private fEmpty and fFull
* Remove unnecesary boxing on fFull.remove()
* Remove main method from ListTest, rename fEmpty to emptyList and rename fFull to fullList
aristotle0x01 pushed a commit to aristotle0x01/junit4 that referenced this pull request Jun 27, 2022
* Set private to fEmpty, fFull and remove unnecesary boxing on ListTest
* Change from protected to private fEmpty and fFull
* Remove unnecesary boxing on fFull.remove()
* Remove main method from ListTest, rename fEmpty to emptyList and rename fFull to fullList
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