PHP: How to start testing a large, existing code base and regression test on a production site?

I am responsible for at least one large amount of existing PHP code that is desperate for tests, and I also need some method of checking the site for errors.

I have been working with PHP for many years, but, unfortunately, is new to testing. (Sorry!).

When writing tests for code that has predictable results, it seems quite simple, I am having problems with how I can check the site in real time to ensure the correct output.

I know that in a test environment I could create a database in a known state ... but are there any suitable methods or methods for testing a live site? Where to begin?

[I know PHPUnit and SimpleTest, but have not yet selected one of them]

+4
source share
2 answers

Unit testing structures, such as PHPUnit, are built more to test the functionality of individual logical units (e.g. classes), rather than the behavior of all live sites. One home name for this is Selenium , a web application testing system. As far as I understand, Selenium tests, in turn, can be integrated with PHPUnit.

Regarding the choice between Simpletest and PHPUnit, see my recent question about PHPUnit vs. SimpleTest - answers to this question, in particular @ Gordon's, managed to convince me from PHPUnit.

+3
source

I am Pekka's second sentence. In addition, I highly recommend using PHPUnit, as it is the de facto Standard in UnitTesting infrastructures in the PHP world.

Another thing you can do is go to phpqatools.org (change: this website is no longer active) and use these tools to analyze your code base, search for dead code, copy and paste, code violations, etc.

Also profile your code with XDebug or Zend Debugger to see how often it runs. Thus, you will not only get an idea of ​​what code you should first test (those that are executed most often), but also how it works, which is a good starting point when you will optimize it after writing unit tests.

Also check:

+2
source

Source: https://habr.com/ru/post/1307804/


All Articles