Software testing tips _ Unit Testing

Source: Internet
Author: User

For more software testing technical articles, visit the http://www.itmarks.cn/

No one tells you what testing is when coding starts. A big question is how to verify the correctness of your code. Of course, you can leave these problems to the system's use process, but it becomes very difficult to find problems in the real code at that time, at this time, once a lot of coupling exists in the code, it becomes more difficult to correct a problem. As a result, we need to discover the problem earlier, and at the same time, we need to convert a coupling complex problem into multiple simple cohesion units, produced by unit tests.

 

In traditional software engineering, unit tests are encoded, while the execution of unit tests is usually the programmer himself, at this time, programmers rely on their own expectations to break down the program unit modules (usually a function or method), execute their desired tests in a certain order, by executing a driver module, the pile model in the calling program is fast, get an expected result, compare the expected results with the expected results. If they are consistent, the test passes. Otherwise, the code can be read or debugged row by row, discover problems hidden in the code, and eventually make the expected results consistent with the expected results.

 

The differences between large-scale software development and small and medium-sized software development begin to improve the concept of unit testing by some well-known programmers outside of China in the software development process and software development methods. Software Engineering is a self-awake and improved system. With the introduction of new agile and XP concepts, test driver development (TDD) has become another concept of unit testing. The difference from the traditional concept is that TDD puts unit tests before code functional modules. The introduction of pre-Tests makes our awesome understanding of OO into bread and water, and we introduce mock object, this is exactly before we build our system with code. This advantage is obvious. The test code exists independently of the developed code. Each test code has a purpose. xunit is unique in TDD testing tools, especially the classic JUnit, the introduction of assertions makes us understand what the purpose of each program unit is. If the person who writes the unit test case and the person who writes the unit under test are the same, the pre-test will enable him to understand the goal of each program before coding, in addition, all goals have established corresponding success standards. During development, he will achieve these goals more accurately. After the development code is completed, he will execute those independent unit tests. We can easily see the results. Due to the introduction of assertions, assuming that each assertions indeed reflect the goals of each function, we need to carefully check the code and find out the problems that cause distortion of the assertions after the assertions fail. Another benefit of doing so is the automation of unit testing, which is the best solution we don't want to see when the screen is output. Assuming that the unit test writers and coders are not the same person, it seems that we have found another good supervision mechanism, the final result is to let the supervised person fulfill the expected test objectives.

For more software testing technical articles, visit the http://www.itmarks.cn/

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.