The difference between-JUNIT3 and 4 of the Basic Learning of JUnit (4)

Source: Internet
Author: User

junit3 and the JUNIT4 the use of the difference is as follows

1. the TestCase class needs to be inherited in JUnit3, but no inheritance is required in JUNIT4 testcase

2. in JUnit3, you need to overwrite the setup and Teardown methods in the TestCase, where the Setup method is called to complete initialization before the test executes, and the Teardown method is invoked when the test results are closed. Used to release the resources in the test use, and in JUNIT4, you only need to add @before before the method, @After

3. when testing a method in JUnit3, the command for the test method is fixed, for example, to test the Addbook method, to write a test method named Testaddbook, and there is no constraint on the method command in JUNIT4. Add @test to the front of the method, which means that this method is the test method in the test case

4. New Assertion Assertthat

5. @BeforeClass and @AfterClass. In JUnit3, if all test case is called only once Setup () and teardown () need to use the Testsetup class

6. Test exception Handling @test (expected = dataformatexception.class)

7. Set timeout @test (timeout = 1000)

8. Ignore Test @ignore

9. Integration Testing

The difference between-JUNIT3 and 4 of the Basic Learning of JUnit (4)

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.