In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Want to complete some scripts, automatically run some application registration, file upload scripts. So take a cursory study of JUnit
1) create a new JUnit case directly
Time limit: @ Test (timeout=200) timeout attribute unit is millisecond
/ / exception test excepted= exception name. places where class is not yet used. Mark first
2) Life cycle
BeforeClass: a method that modifies static and executes it once before the entire class is executed to handle expensive resources, such as connecting to a database
AfterClass: the method that modifies static, as opposed to @ BeforeClass, is used to release resources
Before: a method that modifies public void, which is executed when each test case (method) is executed.
After: a method that modifies public void and executes after the execution of each test case.
Constructor: each test case recreates the current Class instance, and you can see that Constructor is executed twice.
@ Test is equivalent to main.
3) use @ RunWith annotation
For example, if I have a SimpleFunctionTest and a ComplexFunctionTest, how do I execute all of these related case at once?
@ RunWith (Suite.class) @ SuiteClasses ({ComplexFunctionTest.class, SimpleFunctionTest.class})
I haven't used it yet. Mark first.
Assert
Assert is an assertion class provided by JUnit for commonly used test result validation. The functions and methods provided are relatively simple and practical. Here is only a brief introduction to the list:
AssertTrue, AssertFalse: true, false of the result.
AssertThat: use Matcher for custom checking.
AssertEquals, AssertNotEquals: determine whether two objects are equal.
AssertNull, AssertNotNull: determine whether the object is empty.
AssertSame: to determine whether two objects are the same or not, unlike equals, we use "=" to judge.
AssertArrayEquals: determines whether two arrays are equal.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.