Miscellaneous "First day" includes Eclipse common operations, program debug mode

Source: Internet
Author: User

Watch the podcast video notes, thanks

Common operations for Eclipse:

1, the immediate hot version is lower than the compiler version, there will be bad vresion number in class file error;

2. Shortcut keys:

alt+/: Template key

Ctrl+1: Quick Fix

Ctrl+shift+o: Guide Pack

Set code a save when auto format:windows-> preferences->java->editor->save Actions

Code movement: ALT + up and down keys

Reset View: Window->reset perspective ...

3, the typical character stream read and write files:

New FileInputStream ("filename. txt"); int b;  while ((B=in.read ())!=-1) {  // manipulate file contents, read byte save }
Program Debugging methods

1, the file read and write directly when the filename is read by default is the root directory of the current project

2, Debug Breakpoint debugging

View class Source: Ctrl + left mouse button/f3

Forward Backward: Alt + direction left and right

To view class inheritance relationships: F4

F5 (jumping in), F6 (Skip), F7 (jump) Debug mode

Clear Breakpoint: Breakpoint XX Click Clear Breakpoint

3. JUnit Monomer Testing Technology

(1) About the code test method: White box test and black box test, where the white box test structure logic, is visible code test, black box test is Diane Functional test, is an invisible code test

(2) Limitations of white Box testing:

1) It is impossible to test all the code;

2) Difficult, it is impossible to make it easy for others to read the programmer's own code

Due to these limitations, white-box testing is left to programmers to test themselves.

(3) Monomer test: Test code function module, test code single function, is a white box test, JUnit is a white box test of a technology.

(4) The JUnit test steps:

1) Bring the JUnit class library into the project, right-click on the project->preperties->add LIBRARYS->JUNIT->JUNIT4 (support annotations)->ok

2) write a single test case, create a public void method without parameters, add @test in front of the method, each test method is equivalent to the main function, you want to test a use case method alone, click the method right-clicking the run as

(5) Shortcut: Check the class name->new a file->junit test case->new Junit case4-> Select the method you want to test will automatically generate the testing class

(6) In JUnit testing is, when the method is very many times, the content of each method output can not let the programmer one to compare whether the correct time, it is possible to use the assertion in time (automated result detection), the assertion principle: In the Call method money, prepare data and results, compare actual results and expected results are equal

      

Assert.assertequals (actual result, expected result);

(7) JUnit common annotations:

1) @Test: Test method

2) Handle the beginner's mind exception @Test (espected: Error), for example: @Test (espected:java.lang.ArithmeticException), Handling arithmetic exceptions

3) @Ignore: the neglected test method;

4) @Befere: Execute once before each test method executes

5) @Befere: Executes once after each test method is executed

6) @BeforeClass: Static that runs before all test methods start

7) @AfterClass: Static that runs after all test methods have ended

(8) Use assertions to determine test results:

1) assertequals (execeted, Actual);

2) Assertnotnull (object)

3) asserttrue (condition)

4) Assertfalse (condition)

(9) When writing the monomer test, not only to test the correct data, but also to test the incorrect data

Miscellaneous "First day" includes Eclipse common operations, program debug mode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.