JUnit Unit test of Java EE

Source: Internet
Author: User

1 Write a test class and simply understand how junit can be partially used to replace Java's Main method

2 Add annotations on the test class method @Test

3 @Test Modified method requires: Publicvoid Method name () {...}, method name custom recommendation test begins with no parameters. That is, JUnit can only run the modifier to public and return the null argument method with the value type void .

@Before: Executed before the unit test @Test can be used to get some resources

@After: Executes after the unit test @Test and can be used to use some resources

Note : @Before and @After cannot be executed separately , run @Test they will automatically execute

4 Execution :

Select the method you want to execute , right-click run as-->junit Test

Execute multiple methods at once: Select Class , right-click run as-->junit Test

JUnit Unit test of Java EE

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.