JUnit in Eclipse

xiaoxiao2021-03-06  40

I plan to learn to use Juint, I thought it was more laborious, and later used it in Eclipse, I found that it is simple:

Select the class you want to test, create a JUnitTestCase, and fill a pile of things. Can be in this interface:

1. Create several classes such as Setup

2. Create a main method, you can run in the Eclipse interface, 3 interfaces are available

3. Next page Select the method to test

Then call the test class in the test method.

Then tested with Assertfalse, Asserttrue, Assertequals, Assertsame, Assertnull, etc.

Run in junit in Eclipse, do not use the code, Eclipse will automatically find Testcast and execute

If you want to execute the way in Application, you have to write the following code:

Public static void main (String [] args) {

Junit.textui.teStrunner.Run (dbchecktest1.class); // There are 3 interfaces optional Swingui, AWTUI, Textui

}

The simplest use is this

--------------------

Issue a problem, ClassLoader problem

Test a class that uses JDBC, takes class.forname (), and cannot find the driver. ClassPath is invalid, find a solution. However, in Eclipse, you can access it.

-----------

Test in Struts is divided into MVC3:

The M module part of the test is relatively simple, and it can be tested simply with JUnit as above.

The V part is mainly JSP, need to test in the container ... learning ...

The C portion is mainly Action, which requires special test tools, such as ... learning ...

--------------------------------

Attached: Experience

转载请注明原文地址:https://www.9cbs.com/read-59337.html

New Post(0)