Unit testing tool JUnit

   JUnit is a unit testing framework for the Java language. It was founded by Kent Beck and Erich Gamma, has gradually become due sUnit Kent Beck's xUnit family of one of the most successful JUnit JUnit extension has its own ecosystem. Most Java development environment have been integrated as a tool for JUnit unit testing.

   We know Junit is a unit testing framework, then use Junit allows us to quickly complete unit tests.

   Usually we want to test the correctness of the code written this code, you must create a new class, and then create a main () method, then write test code. If you need a lot of code to test it? Then either we will build a lot of main () method to test, either in its entirety written on the inside a main () method. This will greatly increase the complexity of the test, the test reduces the enthusiasm of programmers. The Junit can be a good solution to this problem, simplify unit testing, write a little test that, after the preparation of the code if you find the problem can quickly trace the cause of the problem, reduce return error correction more difficult.

 The eclipse comes with the latest version of JUnit. Do not re-add.

 

 (1) create a class to be JUnit tests.

 (2) creates a corresponding JUnit test class.

 (3) for automatically generated code, supplemented modified to meet the specific test function.

 (4) performing the test.

In this process, also encountered problems, has been an error when executing the test code "No texts found with text runner'JUnit 5 '", because the test code in the classes and methods must be public. After modifying the test is successful, it can be seen from the chart without error, but there is a fail, there have been local and following reason for the failure of the operation.

 

Guess you like

Origin www.cnblogs.com/wx2333/p/10963877.html