PHPUnit Test successful PHPUnit test practice code

Source: Internet
Author: User


16:12 2015/12/8
PHPUnit test success, code written in the WWW directory, named after the class name code file, my file name is
Arraytest.php, the class named Arraytest, internally writes a simple test code:
<?php
Require_once ' phpunit/autoload.php ';
Require_once ' ArrayTeller.class.php ';
Require_once ' phpunit/framework.php ';

Class Arraytest extends Phpunit_framework_testcase
{
Public Function Testnewarrayisempty ()
{
Creates an array of fixture.
$fixture = Array ();

Asserts that the size of the array fixture is 0.
$this->assertequals (0, sizeof ($fixture));
}
/**
* Test method for defining the method that the test tag declares
* @test
*/
Public Function Indexequals ()
{
Creates an array of fixture.
$stack = Array (1, 2, 3);

Asserts that the size of the array fixture is 0.
$this->assertequals (2, $stack [1]);
}
}
And then
CMD dos window into the WWW directory,
Execute PHPUnit arraytest.php, enter to execute
Finally succeeded.

PHPUnit Test successful PHPUnit test practice code

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.