Junit4 Assert static method introduction

Source: Internet
Author: User
Tags assert

The Assert methods in JUnit are all placed in the Assert class, summarizing the classification of the Assert methods in the JUnit class.

1.asserttrue/false ([String message,]boolean condition);
To see if the variable is false or True, the test succeeds if the value of the variable being viewed by Assertfalse () is false, and if True fails, asserttrue () is the opposite;

2.fail ([String message,]);
Directly used to throw an error.

3.assertEquals ([String message,]object expected,object Actual);
You can specify an output error message if you want to determine equality.
The first parameter is the expected value, and the second argument is the actual one.
This method has multiple implementations for each variable

4.assertnotnull/null ([String message,]object obj);
Interpret whether an object is non-empty (not empty).

5.assertsame/notsame ([String message,]object expected,object Actual);
Determines whether two objects point to the same object. Look at the memory address.


7.failnotsame/failnotequals (String message, object expected, object actual)
Output error messages when they do not point to the same memory address or are not equal.
Note that the information is required, and the output is formatted.

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.