phpunit iki kez test çalıştırır - iki cevaplar alır.

0 Cevap php

Bu benim phpunit sınama dosyası

<?php // DemoTest - test to prove the point

function __autoload($className) {
    //  pick file up from current directory
    $f = $className.'.php'; 
    require_once $f;
}

class DemoTest extends PHPUnit_Framework_TestCase {
    // call same test twice - det different results 
    function test01() {
        $this->controller = new demo();
        ob_start();
        $this->controller->handleit();
        $result = ob_get_clean();  
        $expect = 'Actions is an array';
        $this->assertEquals($expect,$result);
    }

    function test02() {
        $this->test01();
    }
}
?>

Bu, test edilen dosya

<?php // demo.php
global $actions;
$actions=array('one','two','three');
class demo {
    function handleit() {
        global $actions;
        if (is_null($actions)) {
            print "Actions is null";
        } else {
            print('Actions is an array');
        }
    }
}
?>

Sonuç $ eylemler null olduğu için ikinci test başarısız olmasıdır.

Benim soru - neden ben iki test için aynı sonuç alamadım?

Bu PHPUnit bir hata mı yoksa php benim anlayış?

0 Cevap