In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the IDEA how to use JUnity tools for unit testing related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that you read this IDEA how to use JUnity tools for unit testing article will have a harvest, let's take a look at it.
What is JUnit?
JUnit is a regression testing framework (regression testing framework) for the Java language, established by Kent Beck and Erich Gamma.
Junit testing is also a programmer test, the so-called white-box test, which requires the programmer to know how the code being tested performs its function and what it does.
II. JUnit configuration of IDEA
(1) add dependent jar packages junit-4.12.jar and hamcrest-core-1.3.jar of junit
Maven project pom configuration:
Maven project pom configuration: junit junit 4.12 test org.hamcrest hamcrest-core 1.3
(2) install the junit4 plug-in
(3) choose to use Junit4 by default
(4) configure the output path
Modify Output Path to: ${SOURCEPATH} /.. /.. / test/java/$ {PACKAGE} / ${FILENAME}
(5) modify the test case template. The package name of the package generated in the template needs to be removed from the test.
Third, generate JUnit4 test cases
Method 1: press the shortcut key Alt + Insert on the java class source code block to be tested. Select JUnit Test- > JUnit 4.
Method 2: press the shortcut key Ctrl + Shift + T. Modify the relevant test cases as needed.
Method 3: locate the cursor to the java class source code block to be tested, select code- > Generate, and the following steps are the same as method 1.
Notes used in Test:
@ BeforeClass uses the method of this annotation to execute before the test class is called
@ AfterClass uses this annotated method to execute the number of @ Test annotated methods in a class before the test class is called and exited, and the following annotated methods are called many times
@ Before executes before each @ Test call
@ After executes after each @ Test call
@ Test uses the method of this annotation as a unit test case, which can be declared multiple times in a test class, and each annotation is @ Test only executed once
@ Ignore test cases that are not executed temporarily will be ignored by JUnit4
This is the end of the article on "how to use JUnity tools for unit testing in IDEA". Thank you for reading! I believe you all have a certain understanding of "how to use JUnity tools for unit testing in IDEA". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.