idea add junit plugin

1. To use idea for junit testing, you need to add the junit plugin

    1. Install the plugin

        File-->settings-->Plguins-->Browse repositories-->Enter JUnit-->Select JUnit Generator V2.0 installation, restart idea.

        

  2. Use the JUnit plugin

      In the class that needs to be unit tested, use the shortcut key alt+insert, select JUnit test, and select JUnit4.

2. The download of the plug-in fails in the above situation, you need to go to the idea official website to download the junit plug-in and add it manually

    1. Plugin download: https://plugins.jetbrains.com/idea/plugin/3064-junitgenerator-v2-0 . The installation is as follows, restart after completion.

   

  

   2. Modify the configuration of JUnitGenerator V2.0.

  1. The automatically generated test code and java class are in the same package, which does not match the standard test directory of the maven project.

     Modify the Output Path to: ${SOURCEPATH}/../../test/java/${PACKAGE}/${FILENAME},

       Default Template select JUnit 4.

      

   2. You need to add junit's dependency jar to the project

    I use: junit-4.12.jar hamcrest-core-1.3.jar (this jar will report an error if it is not imported)

                    Download address: http://central.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar

   Create a new test class in the project and try it

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325517891&siteId=291194637