Testing PHP

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hash: SHA1

Hello everyone,

one area which I never used and I don't know how, is the automated testing of
PHP scripts.

The problem is that I can not image this will work and what will be tested.
eg. will each function be tested ? But how will the test know what will be the
result ?

So do you have to manually define what should be the result of a test, that the
test software knows what is right or wrong ?

Has anybody experience with that and perhaps some links to tutorials ?

thank you,
johannes keßler
Version: GnuPG v2.0.11 (GNU/Linux)


Re: Testing PHP

johannes keßler wrote:
Quoted text here. Click to load it

There are two main ways of automated testing: unit tests and functional

Unit tests test functions, classes, etc. I think SimpleTest is one of
the most known unit test libraries for PHP.

Functional tests test the behaviour of the software. For instance,
Selenium can be used to test a site.

In both cases, you can only test against known results, so you will have
to provide what is right and what is wrong. You feed your code known
input and expect the known output. If the output is different, there is
an error, either in your code or in your test (or in your setup maybe).
For unit tests, an exception is output as well. For some input, your
function or class should escalate, and it is good to test for this

Best regards.

Re: Testing PHP

johannes keßler wrote:
Quoted text here. Click to load it

Code testing is a whole area of expertise itself, much more than can be
explained in a newsgroup.  But it's also common to all languages, not
just PHP, and the principles are the same.  Larger projects have whole
groups of people who's only job is to test software.

These projects hand the design documents to the programmers and testers.
  The programmers write the code according to the design; the testers
create test cases according to those same documents.  Test cases start
at the lowest level (i.e. class or function) and work their way up until
the entire program is tested.

The test cases include both good and bad input, as well as the expected
results.  When there is a difference between the expected results and
the actual ones, the problem is one of three places - either the
programmer didn't write the code correctly, the tester didn't set the
results correctly, or the design document was insufficiently clear (or
was ambiguous).

The programmer can also act as the tester, but this is less desirable
because the programmer knows how he/she designed the code, and will test
according to that.  But on small projects, it's the only way you can do it.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Testing PHP

Jerry Stuckle wrote:
Quoted text here. Click to load it

Good summary.

Re: Testing PHP

On Oct 8, 5:28=A0pm, sheldonlg <sheldonlg> wrote:
Quoted text here. Click to load it

Ass kiss

Site Timeline