Intellij Idea Series guide Jar pack and write unit Test (ii)

Source: Internet
Author: User

I. Original intention

For many beginners, IntelliJ How to import jar package feel very confused, even after searching the relevant articles on the Internet or foggy, this blog through an illustrated way for the reader to clear description, if there are questions please leave a message. Perhaps a lot of Daniel will say, you do not need Maven or gradle to make, how simple, I hereby declare that this article is only for beginners IntelliJ programmer. The author intends to make this blog a series of articles, later on how to use IntelliJ to build maven and Gradle projects.

Two. Import the jar package and write a simple junit

This blog post, created in the Intellij Idea Series Javase Project Creation (i) article, writes a simple junit that demonstrates how to import jar packages in Intellij and how to write unit tests in Intellij.

The author will download the good Junit4.8.2.jar into the F:\libraries path, such as

Create a package in J2SE src, named Add demo1, and then build a class under the packet, called Importjartest.java, please note that the reader "External Libraries" directory currently only "<1.8>", As shown

In IntelliJ, select File->project Structure, shortcut key is CTRL + ALT + Shift + S, as

The following screen appears, select "Modules", then click on the "+" indicated in the graph and select "JARS or Directories"

Select the Junit.4.8.2.jar package that has been downloaded in the F:\libraries directory, as shown in the following screen.

Click "OK" to see the section indicated in the red box below, indicating that JUnit's jar package has been added successfully

Click "OK" to observe the Red Line marking section and JUnit's jar package has been added to the project

Write the code shown in the Importjartest.java file (readers should not care about the contents of the code)

Select the "Begintest" method in the sample code and right-select "Run begintest ()", as

As shown, JUnit runs successfully

Intellij Idea Series guide Jar pack and write unit Test (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.