Original article published on
English source documentation: http://www-128.ibm.com/developerworks/library/j-test.html
If neededReprintedContact the translator's chdwu@bestreme.com
DueExtreme ProgrammingIn recent yearsUnit TestGradually become meSoftware DevelopmentAn indispensable and important part in the process. Extreme programming requires us to perform unit tests on every function we have done and manage these tests well, we should not integrate any new functions before all unit tests pass. The advantage of this approach is that developers can be confident in the code they write (rather than blindly self-reliant ).
At first, I thought that since we already have a unit test, there is no need to spend more timeFunction TestingBut now I know this is a wrong idea: Unit Testing and functional testing are quite different. It took me a long time to understand the differences between unit testing and functional testing. I also learned how to better use unit testing and functional testing to improve our software development process.
This article explores the differences between unit testing and functional testing and how we can use these two tests to support our software development.
Testing and software development process
As a developer, testing is very important. We must stick to testing our code throughout the software development process, instead of taking testing as a product of a special stage of software development: testing should never be a routine task that begins one day before the software is submitted. How can you know that our software has been released? How do you know that when I fixed this small bug, it didn't cause a more serious system bug? How do you know whether the current system can expand some features that you have not yet imagined? Test! Unit testing and functional testing must be an integral part of our software development process.
Unit testing should be a core part of your code writing, especially when the project is tight but we still need to ensure the quality. Unit Testing is very important. You should even complete unit testing before writing your code.
Unit test:
-Helps to reproduce the most effective design as much as possible
-Helps provide an optimal file organization structure
-Helps determine whether a class is complete
-Gives developers full confidence in their code
-"Is the basis for rapid reconstruction
Unit testing helps to form systematic design documents that can be continuously improved. These documents are of great significance in the software development process. Most of the time, it is better to document the use case into a class than to list the actual use cases of a lot of encoding. Let's look at unit testing: it provides a series of regular input or data, we use a series of actual use cases to tell us what the classes we write have done. In this case, this design document is always up-to-date, because we must pass the unit test.
You should write unit tests before writing code. The advantage of doing so is to provide yourself with a design solution that can be tested, which can help you think better, this will simplify the design. You don't have to worry about what will happen in the future, and you don't have to spend time implementing unnecessary functions. First, writing a unit test helps you understand when the code is completed: After all tests are passed, our task is completed.
Finally, unit testing gives you a high degree of confidence in your code, which helps us make better products. After you modify your code, we will run our test. If there is any problem, we can quickly find out where the damage caused by our modification is.
Functional testing is even more important than unit testing because it is used to detect whether our system meets the release requirements. Function testing is used to determine whether our system is available.
Function test:
-An effective method for determining whether to meet user requirements
-Let users and developers know that our system has met these user needs
The traditional development process is to determine whether to meet the user's needs from the actual use. Usually people need to make great efforts to figure out the actual use cases and try to summarize them. When they finish theseWorkThen they only put a piece of paper in their hands, and functional testing is like determining the actual use case. Extreme Programming describes these concepts. Extreme programming needs to define these functions in advance (this process needs to be completed by the project team and the user), and functional testing is its product. If there is no functional testing, what we can't do is beautiful.
Functional testing can check out some Software defects left by unit testing, so that developers are more confident in their code, because unit testing will still leave many bugs behind, it may cover all parts of the Code but not all parts of the system. Functional Tests can expose issues not involved in unit tests. Of course, an automated and sustainable functional test cannot identify all the problems in the system, but it can find more bugs that cannot be found in unit tests.