×ðÁú¿­Ê±

ÔõÑù¾ÙÐÐThinkPHP6µÄµ¥Î»²âÊÔ£¿

Ëæ×Å»¥ÁªÍøµÄÉú³¤ £¬ÏÖÔÚµÄÈí¼þ¿ª·¢±äµÃÔ½À´Ô½ÖØ´ó £¬ÔÚ´úÂëµÄÖÊÁ¿ºÍÎȹÌÐÔÉ϶¼ÓÐ×ÅÔ½À´Ô½¸ßµÄÒªÇó¡£µ¥Î»²âÊÔ£¨unit testing£©ÊÇ°ü¹ÜÈí¼þÖÊÁ¿ºÍÎȹÌÐÔµÄÒ»ÖÖÓÐÓÃÊֶΡ£ÔÚphp¿ª·¢ÖÐ £¬thinkphpÊÇÒ»ÖÖ¼«Îª³£ÓõÄmvc¿ò¼Ü¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚthinkphp6ÖоÙÐе¥Î»²âÊÔ¡£

Ò»¡¢Ê²Ã´Êǵ¥Î»²âÊÔ

µ¥Î»²âÊÔµÄÄ¿µÄÊǶԳÌÐòÄ£¿é¾ÙÐÐ׼ȷÐÔÄ¥Á·¡£µ¥Î»²âÊÔÊÇÈí¼þ¿ª·¢ÖеÄÒ»ÖÖ²âÊÔÒªÁì £¬×¨ÃÅÕë¶Ô³ÌÐòÄ£¿é£¨Unit£©¾ÙÐÐÉè¼ÆºÍÖ´ÐеIJâÊÔ¡£µ¥Î»²âÊÔÐèÒª³ÌÐòÔ±±àдµ¥Î»²âÊÔÓÃÀý £¬È»ºóʹÓÃÌض¨µ¥Î»²âÊÔ¹¤¾ßÖ´ÐÐÕâЩÓÃÀý £¬ÑéÖ¤³ÌÐòÄ£¿éµÄ׼ȷÐÔ¡£

ÔÚ¾ÙÐе¥Î»²âÊÔµÄÀú³ÌÖÐ £¬ÎÒÃÇ¿ÉÒÔ·¢Ã÷Ä£¿é¼äµÄñîºÏ¹ý¸ß £¬»òÕßijЩÇéÐÎÏÂÎÞ·¨Õý³£ÔËÐÐ £¬´Ó¶øʵʱ·¢Ã÷²¢½â¾öÎÊÌ⡣ͬʱ £¬µ¥Î»²âÊÔÒ²ÓÐÖúÓÚÌá¸ß´úÂëÖÊÁ¿ºÍ¿Éά»¤ÐÔ £¬Ìá¸ß¿ª·¢Ð§ÂÊ £¬Ëõ¶Ì¿ª·¢ÖÜÆÚ¡£

¶þ¡¢ThinkPHP6µÄµ¥Î»²âÊÔ

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ThinkPHP6µÄµ¥Î»²âÊÔ½ÓÄÉÁËPHPUnit¿â £¬ÊÇÏÖÔÚPHPÁìÓòÖÐ×îÊ¢ÐС¢×î³ÉÊìµÄ²âÊÔ¿ò¼ÜÖ®Ò»¡£PHPUnit¾ßÓи»ºñ¶øÍêÉƵĹ¦Ð§ £¬Ö§³ÖÖÖÖÖÀàÐ͵ĶÏÑÔ £¬Äܹ»¾ÙÐÐÁýÕÖÂÊÆÊÎö £¬»¹Ö§³Ö²âÊÔЧ¹ûÊä³öºÍ²âÊÔ±¨¸æÌìÉúµÈ¹¦Ð§¡£

ÔÚThinkPHP6ÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý½¨Éè²âÊÔÀàÀ´¾ÙÐе¥Î»²âÊÔ¡£ÀýÈçÎÒÃǽ¨ÉèÒ»¸ö²âÊÔÀàtestsunitDemoTest.phpÀ´²âÊÔ×ðÁú¿­Ê±³ÌÐò£º

<?php
namespace testsunit;

use PHPUnitFrameworkTestCase;

class DemoTest extends TestCase
{
    public function testAdd()
    {
        $this->assertEquals(2+2, 4);
    }
}

µÇ¼ºó¸´ÖÆ

ÉÏÃæÕâ¸öʾÀý²âÊÔÁËÒ»¸ö±»²âÒªÁì testAdd() £¬Í¨¹ý $this->assertEquals() ÒªÁì¾ÙÐжÏÑÔ £¬ÅÐ¶Ï 2+2 ÊÇ·ñ¼´ÊÇ 4¡£ÕâÊÇÒ»¸ö¼«Îª¼òÆӵIJâÊÔÓÃÀý £¬Ö¼ÔÚ˵Ã÷ÔõÑù¾ÙÐвâÊÔ¡£ÏÖÕæÏàÐÎÖÐÎÒÃǽ«²âÊÔ¸üÖØ´óµÄ¹¦Ð§Ä£¿é¡£

½ÓÏÂÀ´ £¬ÔÚÏÂÁîÐÐÖÐÖ´ÐÐÒÔÏÂÏÂÁî £¬¾Í¿É¾ÙÐвâÊÔÁË£º

./vendor/bin/phpunit tests/unit/DemoTest.php

µÇ¼ºó¸´ÖÆ

ÔËÐвâÊÔºó £¬PHPUnit½«Êä³ö²âÊÔЧ¹ûºÍÁýÕÖÂʱ¨¸æµÈÐÅÏ¢¡£

Èý¡¢µ¥Î»²âÊԵļ¼ÇÉ

Êý¾Ý¸ôÀë

µ¥Î»²âÊԵIJâÊÔÇéÐÎÓ¦¸Ã¸ôÀëÆäËûÇéÐÎ £¬²»Ó¦¸ÃÓëÆäËû²âÊÔÓÃÀý¹²ÏíÊý¾Ý¿â»òÎļþ×ÊÔ´µÈ¡£Õâ¿ÉÒÔ×èÖ¹²âÊÔÓÃÀýÖ®¼äÏ໥ӰÏì £¬Í¬Ê±Ê¹µÃ²âÊÔЧ¹ûÔ½·¢×¼È·¡£

²âÊÔÁýÕÖÂÊ

²âÊÔÁýÕÖÂÊÊÇÖ¸²âÊÔÓÃÀýÄܹ»ÁýÕÖµ½³ÌÐòÖеÄÄÄЩ´úÂ벿·Ö¡£²âÊÔÁýÕÖÂÊÔ½¸ß £¬Òâζ×ÅÎÒÃDzâÊԵĴúÂë¶ÎÔ½¶à £¬´úÂëµÄÖÊÁ¿Ò²Ô½ÈÝÒ×»ñµÃ°ü¹Ü¡£ÔÚPHPUnitÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓà –coverage-html ²ÎÊýÌìÉú²âÊÔÁýÕÖÂʱ¨¸æ£º

./vendor/bin/phpunit tests/unit/DemoTest.php --coverage-html coverage/

µÇ¼ºó¸´ÖÆ

ÌìÉúµÄÁýÕÖÂʱ¨¸æ½«ÉúÑÄÔÚ coverage Ŀ¼Ï £¬ÎÒÃÇ¿ÉÒÔÔÚä¯ÀÀÆ÷ÖÐÉó²é¡£

²âÊÔʧ°Ü´¦Öóͷ£

µ±²âÊÔÓÃÀýÖ´ÐÐʧ°Üʱ £¬ÎÒÃÇÐèҪʵʱ¶¨Î»Ï¢Õù¾öÎÊÌâ £¬²»È»²âÊÔʧ°ÜµÄ±¨¸æ½«ËÁÎ޼ɵ¬µØÊä³ö¡£ÔÚPHPUnitÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý –stop-on-failure ²ÎÊýÔÚ²âÊÔʧ°Üʱ×èÖ¹²âÊÔ £¬Ò²¿ÉÒÔʹÓà –debug ²ÎÊýÔÚ²âÊÔʧ°ÜʱÆôÓõ÷ÊÔģʽ¡£

ËÄ¡¢×ܽá

ͨ¹ýµ¥Î»²âÊÔ £¬ÎÒÃÇ¿ÉÒÔ·¢Ã÷³ÌÐòÖÐÒþ²ØµÄ¹ýʧ»òÎÊÌâ £¬²¢ÊµÊ±´¦Öóͷ£ £¬Ìá¸ß´úÂëÖÊÁ¿ºÍ³ÌÐòÎȹÌÐÔ¡£ÔÚThinkPHP6ÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃPHPUnit¿â¾ÙÐе¥Î»²âÊÔ £¬ÕâÊÇ°ü¹Ü³ÌÐòÖÊÁ¿ºÍÎȹÌÐÔµÄÓÐÓÃÊֶΡ£Í¬Ê± £¬ÎÒÃÇ»¹ÐèҪעÖØһЩ¼¼ÇÉ £¬ÈçÊý¾Ý¸ôÀë¡¢²âÊÔÁýÕÖÂÊ¡¢²âÊÔʧ°Ü´¦Öóͷ£µÈ¡£

ÒÔÉϾÍÊÇÔõÑù¾ÙÐÐThinkPHP6µÄµ¥Î»²âÊÔ£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿