Inline tests are tests embedded directly in the DOC comments of the script being tested. Such a chip, as far as I know, is in Python, although I could not find a clear description. In any case, I liked the idea, since inline tests have a number of advantages compared to the usual ones, which I will explain below. Therefore, I want to offer you a tool for running such tests for PHP. So, what are the advantages of inline tests compared to conventional unit tests (PHPUnit, etc.)?
Benefits
Simplicity and speed of adding tests : that is to say, sometimes you want to write a test, but when you remember that you have to create the entire folder hierarchy for this class (for example, App_Module_Class), then create the file and test class, write the same bored code checks, then look for, where is this PHPUnit located and how to launch it correctly - hands fall. And it is not a pity to do this if the test is complex and important, but when it is simple ...
Inline-tests can supplement / replace the documentation of the method : indeed, it is sometimes easier for the programmer to understand the essence of the code by reading what and with what parameters it returns, rather than reading the description.
Inline tests can be written even for private methods of a class : since the startup script actually extracts functions and methods from the context, it does not matter whether they are private or public.
They can not be lost : the tests will always be with the code.
Of course, the scope of such tests is quite narrow, there are 2 limitations: ')
Restrictions
It is suitable only for simple tests : first, the test needs to fit in one line of the comment, and second, a complex test using the interrelation of several functions cannot be written.
Only suitable for isolated functions / methods : the function must communicate with the outside world only through arguments and a return value.