Junit course (1)

Source: Internet
Author: User
(Version Beta 1.0)

The Junit tool is used for unit testing and is an essential tool in extreme programming. Tools that must be mastered by Java developers.
First, risks are everywhere in the process of software development. Fundamentally, we cannot eliminate these risks, but we can test to reduce the risks and improve the reliability of development, and the final software quality.

So what is the responsibility of the test we are talking about? The most important part of testing is to ensure the quality of development at each stage of development and discover defects in the software. Then, it is to verify whether the developed products meet the needs of users, that is, the availability of software functions is determined by the response of some sample data in the user's use process during the testing process, so as to improve the existing defects.

The defect here refers to the inconsistency with the "Software Requirement Specification". Because of the inconsistency, it cannot meet the user's needs.

For the test itself, it can be divided into static testing, that is, testing is conducted through review and other non-running means without running the program. It mainly checks whether some standards and specifications are met. Dynamic Testing is to run programs to test the functions and status of each part based on the running status.

From another perspective, there are other types of tests, such as sorting by order:
Unit Testing (Unit Testing) is the most basic and important Testing method, also known as module Testing. It is completed by developers during the development process and requires 100% compliance.
Integration testing, also known as assembly testing, ensures that communication and collaboration between modules run smoothly.
System testing, including the external running environment.
Acceptance Test: The overall test conducted by the customer according to the preliminary documents, mainly based on static tests.
Regression testing.
In addition, there are other types of angles, such:
Function Testing, structure testing, black box testing, and white box testing are discussed in most of the test-related books.

I. Next we will discuss unit testing in detail.
1) Scope of attention, limited to unit modules and the like (such as classes and methods)
2) code analysis and testing
3) function analysis and testing
4) structure analysis and testing
5) Error-oriented analysis and testing

Unit Tests design test cases from within a module or class to discover possible internal errors. I/O conditions and program logic are understood based on detailed design manuals and program lists, and white-box test cases are used. It can identify and process all input and irrational operations.
From the module perspective, a complete module must cover the following aspects: Module Interface, error processing, local data structure, boundary conditions, independent paths, and so on.

A. in the Module Interface Test, you must check the incoming and outgoing data streams of the module at the beginning of the unit test. For example, if the parameter input of the call module is correct, whether the parameters passed when the module calls the submodule are correct, and whether the global changes are consistent among the modules.
The following problems need to be considered during internal and external memory Interaction:
File attributes (especially in Linux and other systems)
Whether the Open and Close statements are correct
Whether the buffer capacity matches the record length
Whether the file has been opened before reading and writing
Whether the file is closed when File Processing ends
Check and handle I/O errors

B. Test the local data structure
Whether the data type description is correct and consistent
Whether there are unassigned values or uninitialized variables
Whether the initial value or default value is correct
Whether the name is incorrectly spelled
Consistent data types
Impact of global data on modules

C. Path test. The path here refers to the execution path of the program.
Select appropriate test cases to test important execution paths
Design test cases to find errors caused by incorrect calculation, incorrect comparison, or abnormal control flow.
Test the basic execution path and cycle

D. error handling test
Difficult to understand error description
Error Description: whether the error can be located
Whether the error prompt matches the actual error
Are error handling conditions correct?
Whether the error condition has caused system intervention before error handling

E. Border Testing
Carefully design dedicated test cases to test conditions near the boundary value
If the running time is required, you need to perform a special test on the Key Path to determine the impact on the time in various situations.

Unit test steps:
A module is generally not an independent program. When testing a module, you must consider its connection with the surrounding environment. It is mainly used to simulate a connection module with an auxiliary module. That is, the driver module and the pile module are used.
If a module contains multiple capabilities, you need to divide the test into several small programs, perform unit tests on each part, and add performance tests to key modules.
Interconnection tests are required for modules that support standard procedures. This is called a module test, which distinguishes a unit test.

2. regression testing
Regression testing is a process of re-running previous tests. It is mainly used to check the programs that haven't changed in subsequent development. This is mainly because the newly developed content affects the operation of the previously developed modules. The goal is to ensure the correctness of the overall functions of the software. Regression testing is necessary as long as new programs may affect old functions.

To be continued...

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 1538149

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.