PHPUnit Test Learning 2 Classification summary assertions involved in what aspects

Source: Internet
Author: User
Tags format definition log log


11:27 2015/12/9
PHPUnit Test Learning 2, what are the aspects of categorical summary assertions
It is recommended that Windows quickly open cmd under a path and enter the test state:
In the folder, press and hold shift+ right mouse button, this time you will see the picture below. Then click on
Just open the command-line window here.
Reference: http://www.jb51.net/os/windows/111622.html
General open cmd Enter the directory too much trouble too slow.

Basic (Assertnotequals):
True or false is null equality unequal size equals type same
Class (Assertclasshasstaticattribute):
Instance, Object (assertinstanceof):
An object is an instance of a class that is not an instance of an object
string (Assertstringmatchesformat):
Whether a string is the beginning of whether a regular expression (ASSERTREGEXP) conforms to a defined
format (for example, %i%s, etc.)
Class attribute (assertattributecontains):
Attribute type has type only type contains a property of a certain type has a true or false equality of equal unequal
contains a static property contains a static property size equal to a certain property belongs to a class is a certain kind
Type
Array:
contains an index
function:
return value return type
file (assertfileexists):
file exists or not file under the same file path type:
Assertstringmatchesformat assertion $string conforms to $format definition
The format of a piece of content in a file, such as%i%s, and so on
CSS (assertselectcount):
A selector in a document has n conforming elements
(Assertselectequals ("#binder. Name", "Chuck", true, $xml);//
Some name equals Chuck)

XML ( assertequalxmlstructure):
DOM node is the same,
Assertcontainsonly
Assertcontains (can assert a character in a string)
Assertattributegreaterthan (the property of a class is somewhat larger)
Assertlessthan
Assertattributeinternaltype

more complex Assertions can be formulated using the
Phpunit_framework_constraint classes
More complex assertions are available through Phpunit_framework_ The constraint class to make a

Phpunit_framework_constraint_attribute Attribute
(Phpunit_framework_constraint $constraint, $attributeName)
Constraints allow another constraint class to be a property of a class or object
...........

Very useful:
Setup and teardown these two methods to solve this problem.
Setup is called before each test case of the class is run, and you can do some related program initialization in it.
's work
The Teardown method is called after each test case has finished running, and you can perform some
Off the cleanup work
Note that it is not necessary to write the setup to write Teardown,teardown
Use resources to compare large objects, such as databases on a connection, open files, and so on.
There are many other ways to do this:
Assertion before/After calling test case before/after class call occurs before/after the call is not called
When a successful test case
Parameters:
Specifies the format of the log log that generates the specified format overwrite the log lists the available test group realistic measurement
Test process settings result display color encountered first failure first error first Skip first unfinished
The test is to stop a test that does not define any assertion generation Profile test class read test code open grammar Check
Before trying to run bootstrap php file path in PHP inxlude_path add path settings php configuration genus
Output debugging information (such as when the name of the test begins to execute)
This is not as good as it is, the assertion function is divided into classes:
Http://blog.sina.com.cn/s/blog_6d425e1a010199gd.html

PHPUnit Test Learning 2 Classification summary assertions involved in what aspects

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.