“Web interface” to PHPUnit tests?

前端 未结 11 836
臣服心动
臣服心动 2020-12-02 15:37

Is there a simple \"Web interface\" to running PHPUnit test suites? i.e. a PHP script that runs the test on the command line, and outputs a nicely formatted HTML result.

11条回答
  •  借酒劲吻你
    2020-12-02 16:08

    If you don't care about reformatting the output and just want to run PHPUnit from a web page, you can do so with some PHP code like this:

    
    

    The file src/load.php is just a bunch of includes to include the classes. The output then looks like this:

    #!/usr/bin/env php
    PHPUnit 4.1.2 by Sebastian Bergmann.
    
    ........................
    
    Time: 122 ms, Memory: 3.25Mb
    
    OK (24 tests, 43 assertions)
    

    Just ignore that first line and you can see the results.

    I'm shocked that PHPUnit does not include a basic way to do this. Some classes may be dependent on the web server. Do we just not test those? Some sites have you upload your files and don't allow command line executions.

提交回复
热议问题