IDEA generates junit test code and executes it


IDEA is the 2017 version

because it is too cumbersome to map, please understand the use of IDEA by yourself.
The first part is to install the junit generation plug-in
 
1 File-->Settings-->Plugins Enter junitGenerator V2.0 and install it. A restart is required, just restart.

The second part generates Junit code

1 Set the template
  File--?Settings-->Other Settings --> junit Generator OutPut Path is set to ${SOURCEPATH}/../../test/java/${PACKAGE}/${ FILENAME}
  template is set to Junit4, the code template of Junit4 can be determined by itself.

2 Generate code
   Use shortcut keys ALT + INSERT in the target java file to generate test code, and select JunitTest --Junit4 to generate relevant test classes.

3 Execute the test code
   Project Structure -->Project Settings -->Modules , if your test project is already in the Modules list, just mark as the java code and resource corresponding to your project on the source tab in the right column That's it, Tests and Test Resource respectively.
If you can't find your project, click the green plus sign, Import Module, and select your module.
Follow the steps above after importing.
 
The above operation is completed, go back to your project, the corresponding area should turn green.
At this time, right-click the method name on your test class to perform related tests, or you can run the entire test class completely. If you have any questions, please leave a message, thank you.
Good luck.

Guess you like

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