Using content assist
In this section you will use content assist to finish writing a new
method. Open the file junit.samples/VectorTest.java in the Java
editor if you do not already have it open and select the testSizeIsThree()
method
in the Outline view. If the file doesn't contain such a method see
Adding new methods
for instructions on how to add this method.
-
Replace the TODO comment with the following lines.
assertTrue(fFull.size() == 3);
Vector v = new Vector();
for (int i=0; i<3; i++)
v.addElement(new Object());
assert
-
With your cursor at the end of the word
assert
, press Ctrl+Space to activate content assist. The content assist window with a list of
proposals will appear. Scroll the list to see the available choices.
-
With the content assist window still active, type the letter 't'
in the source code after
assert
(with no space in between). The list is narrowed and only shows entries
starting with 'assert'. Single-click various items in the list to view any available Javadoc help for each item.
-
Select
assertTrue(boolean)
from the list and press Enter. The code for the assertTrue(boolean)
method is inserted.
-
Complete the line so that it reads as follows:
assertTrue(v.size() == fFull.size());
-
Save the file.
Java editor
Java Content Assist
Java Editor Preferences