In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 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.
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.