Efficient shortcut keys in eclipse
When I learned about the usage of these shortcuts, I felt really excited, and I didn't think that there were so many amazing features in eclipse that really improved efficiency.
Content Tip alt+/
Content tips for entering a standard library or keyword
High-speed repair ctrl+1
When the editor displays an error. Don't think about it. Press ctrl+1 for high-speed repair first
Guide Pack Ctrl+shift+o
This shortcut is capable of high-speed guides. For example, the collection class was used, but the corresponding package was not previously imported. The ability to pass the shortcut key
Format code block ctrl+shift+f
View ALT + forward and backward arrow keys
This function is more practical when debugging or viewing the source code.
Join Gaze ctrl+shift+/
Remove Gaze ctrl+shift+\
View method Description F2
Up and down copy row ctrl+alt+ up and down keys
Can be used to copy up and down the line where the cursor is located
Move row up and down ALT + up and down keys
Can be used to move up or down the row of the cursor
View the inheritance relationship for a class ctrl+t
This method is used to view the inheritance tree for the specified class. Especially in the learning framework when viewing the source code will be a lot of use
View Source Ctrl+shift+t
Enter the source code to view in the pop-up box open type
View shortcut key Settings ctrl+shift+l
See all the shortcuts in eclipse
Set up to view the source code under Eclipse
Press CTRL + LEFT mouse button Click to see the standard class library, but the assumption is not properly configured, there will be errors
The process of resolving the method is as follows:
- Click on the form (window)--"Java"--Installed JRE ("Installed JREs")
- The JRE environment in the system appears in the list box on the right. You can create your own JRE and click Edit to show the edit form
- Select the Rt.jar file: ". \jre\lib\rt.jar "and unfold it
- Expand to see "Source connection: (none)" or "Source Attachment: (None)", double-click the item. Select the "src.zip" file under your JDK folder
- OK and complete configuration
Debugging Debug
- skip step in F5
- Skip step Over, F6
- jump out of step out, F7
- drag and drop onto frame drop to frame
go to the first line of the currently debugged method, which is more useful, with At debug time the current step skips and goes back
- jumps to the next breakpoint resume->f8
View breakpoints in a breakpoint (breakpoints) view or clear all breakpoints
JUnit Test Frame Basic use
- Write a new test class file
- Add annotations to the test method written @Test
- Right-click the method you want to test in the outline (Outline) view. Execute the configuration (run as) to execute the method
- If you want to test all the methods in the class, you can click on the class to test
For example, to test a class
public class Person { public void run() { System.out.println("run!!"); } public void eat() { System.out.println("eat!!"); }}
Among the test classes such as the following
import org.junit.Test;//Person的測试类public class PersonTest { @Test public void testRun(){ Person p = new Person(); p.run(); } @Test public void testEat(){ Person p = new Person(); p.eat(); }}
The special method of test class @before, @After
import org.junit.after;import org.junit.before;import Org.junit.test;//person test class public class persontest {private person p; @Before public void before () {System.out.println ("before"); p = new person (); } @Test public void TestRun () {p.run (); } @Test public void Testeat () {p.eat (); } @After public void after () {System.out.println ("after"); }}
The @before, @After two special methods are added here. Both of these methods are executed successively when each method executes. its purpose is. Writes the operation of the initialization resource to the @before and writes the action of releasing the resource to @after .
The printed result is
Before
eat!!
After
Before
run!!
After
@BeforeClass, @AfterClass
The two methods are designed when classes are loaded and classes are released.
Note that the method of labeling here must be a static method.
Assert assert
Assert.assertEquals("2",p.run());
If this method does not meet the expectations, then the test does not pass.
Reprint please indicate the author Jason Ding and its provenance
GitHub home page (http://jasonding1354.github.io/)
CSDN Blog (http://blog.csdn.net/jasonding1354)
Jane Book homepage (http://www.jianshu.com/users/2bd9b48f6ea8/latest_articles)
Efficient shortcut keys, debugging, and JUnit in eclipse