V
V
Vyacheslav2016-08-01 13:34:00
PHP
Vyacheslav, 2016-08-01 13:34:00

Why are PHP unit tests run from the command line?

From what I understand, most php unit testing frameworks run tests from the command line (i.e. from the terminal). Why is that? Why not run the same test php script from a browser? For example: http:// project-host/tests/tests.php
Somewhere I read about the "green bar" that shows the percentage of tests passed, is it only possible to display a beautiful test report in the browser? There is also such a problem that on my Macbook, php 5.3 is installed in the system, and in my browser MAMP is running as a server and PHP 5.6 is there. How then to run tests from the terminal in php 5.6?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
werevolff, 2016-08-01
@werevolff

Why do you need unit tests if you don't understand what they are?
Tests in PHP run in the console for the same reason they run in many other languages. It must be understood that PHP did not start as a real programming language, but as a template engine for cgi applications. Now PHP is a programming language. The fact that you use it as a templating engine on your Mac doesn't do you any credit.
And, yes, mumps, lamps, and wumps are not the best option for PHP programmers who need unit tests. Try Docker or Vagrant.
And one more small addition: PHP has a low entry threshold. This means that most ordinary computer users will be able to create a page on it with minimal difficulty. They definitely don't need unittests. Like most developers who make websites on CMS or frameworks. And those who really need tests do not need WebUI for them.

S
Saboteur, 2016-08-01
@saboteur_kiev

"Somewhere I read about the" green strip ", which shows the percentage of tests passed, it can only be done in the browser - a beautiful test report?"
Unit tests running from the console can easily generate a beautiful html report on their own, even with ajax that you will view from the browser.
You have some kind of rubbish in the terminology and presentation of how everything works.
Browser - DOES NOT know how to execute php scripts. The browser can parse html and execute javascript from it. Therefore, it is not possible to run php unit tests in a browser.
You can install a thread engine, such as teamcity / jenkins / hudson, in which you can set up jobs, and then they can be "launched through the browser". But to execute a PHP script, it needs php, not a browser.

A
Anton, 2016-08-01
Reytarovsky @Antonchik

If you need to graphically run tests, you can use phpstorm looks like thisrun_console.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question