Jump to content

Run tests: Difference between revisions

From NusaATK
No edit summary
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Hier hoort informatie over automatische tests voor het [http://www.lastcraft.com/simple_test.php SimpleTest framework] voor Platform (>M6) en ATK (>5)
Hier hoort informatie over automatische tests voor het [http://www.lastcraft.com/simple_test.php SimpleTest framework] voor Platform (>M6) en ATK (>5)


== Uitvoeren van tests ==
== Run tests ==
Tests kan je uitvoeren door te browsen naar test.php in de map waar index.php ook staat.
Tests can be executed by browsing to test.php (same folder where index.php is).
   Dus als je voor het browsen naar [http://www.relaxnow.nl/ http://www.relaxnow.nl/] zou gaan
   So for browsing a site you go to [http://www.relaxnow.nl/ http://www.relaxnow.nl/]  
   en voor de beheeromgeving naar [http://www.relaxnow.nl/platform/admin/ http://www.relaxnow.nl/platform/admin/]  
   And for the admin you go to [http://www.relaxnow.nl/platform/admin/ http://www.relaxnow.nl/platform/admin/]  
   dan is de testomgeving te vinden op [http://www.relaxnow.nl/test.php http://www.relaxnow.nl/test.php]
   then you can find the test on [http://www.relaxnow.nl/test.php http://www.relaxnow.nl/test.php]


Alsmede door het commando '[[sph]] test' uit te voeren in de root van een Platform installatie.
ATK will search the entire application for .php and .inc files with 'test_' in the filename, execute the setUp() function, run the 'test_' functions and finally execute the tearDown() function.


'''TIP:''' sph test kent ook een --dontmail flag. Dus als je 'sph test --dontmail' uitvoert zal die niet mailen
== Run Selective ==
naar de mensen waar die normaal gesproken naar zou mailen.


ATK zal dan zoeken door heel de applicatie en zal alle .php en .inc bestanden waar 'test' in de bestandsnaam staat openen, de setup() functie uitvoeren, daarna alle functies uitvoeren die met test_ beginnen en als laatste de teardown() functie uitvoeren.
If you want to test a single module, you can use the atkmodule parameter:
  test.php?atkmodule=modulename.  
ATK will execute only the tests it can find in that module.


== Selectief uitvoeren ==
If you want to execute the tests of a single testcase you can do something like this:
  test.php?include=class.test_mytest.inc
The test framework will only execute the 'test_' functions in this single testcase.


Als je alleen 1 enkele module wil testen, dan kun je test.php?atkmodule=modulenaam uitvoeren. Hij voert dan alleen de tests uit die hij in die module kan vinden.
'''TIP:''' If you use the include option the framework must still search the entire application for this testcase, since it does not keep track of their locations. This might take several valuable seconds and use quite some memory. This is why there is another test option for running a single testcase where you can include the location:


Als je enkel de tests van een bepaald bestand wil uitvoeren kan je ook
Example:  
  test.php?include=class.test_eentest.inc
gebruiken in je URI, het test framework zal dan enkel dat bestand uitvoeren.
 
'''TIP:''' Als je de include variabele gebruikt met enkel het bestandsnaam dan moet het framework nog steeds heel de applicatie doorzoeken, bij grote Platform sites kan dit wel 8 seconden duren en veel geheugen kosten. Er is dan ook de optie om een test class direct te draaien: de 'class' variabele. Het framework zal dan het zoeken overslaan en enkel die testklasse draaien.
 
Voorbeeld:  
   test.php?class=atk.db.testcases.test_atkdb
   test.php?class=atk.db.testcases.test_atkdb


Dit zal ./platform/atk/db/testcases/class.test_atkdb.inc laden en uitvoeren voor een Platform installatie.
This will load ./platform/atk/db/testcases/class.test_atkdb.inc and perform its tests.


Dit werkt ook met bestanden die zowiezo niet gevonden zouden worden als test bestand (m.a.w. bestanden zonder 'test' in de bestandsnaam). In dat geval zoekt hij zelf de bijbehorende testcases op.
The class option also works for files that would not be found because they don't have 'test_' in the filename. Since the test framework does not need to search for testcases, it will simply load any given testcase.


Voorbeeld:
Example:
   test.php?class=atk.db.atkdb
   test.php?class=atk.db.atkdb


== Writing tests ==
== Writing tests ==
See: [[Writing tests]]
See: [[Writing tests]]

Latest revision as of 08:58, 11 March 2011

Hier hoort informatie over automatische tests voor het SimpleTest framework voor Platform (>M6) en ATK (>5)

Run tests

Tests can be executed by browsing to test.php (same folder where index.php is).

 So for browsing a site you go to http://www.relaxnow.nl/ 
 And for the admin you go to http://www.relaxnow.nl/platform/admin/ 
 then you can find the test on http://www.relaxnow.nl/test.php

ATK will search the entire application for .php and .inc files with 'test_' in the filename, execute the setUp() function, run the 'test_' functions and finally execute the tearDown() function.

Run Selective

If you want to test a single module, you can use the atkmodule parameter:

 test.php?atkmodule=modulename. 

ATK will execute only the tests it can find in that module.

If you want to execute the tests of a single testcase you can do something like this:

 test.php?include=class.test_mytest.inc

The test framework will only execute the 'test_' functions in this single testcase.

TIP: If you use the include option the framework must still search the entire application for this testcase, since it does not keep track of their locations. This might take several valuable seconds and use quite some memory. This is why there is another test option for running a single testcase where you can include the location:

Example:

 test.php?class=atk.db.testcases.test_atkdb

This will load ./platform/atk/db/testcases/class.test_atkdb.inc and perform its tests.

The class option also works for files that would not be found because they don't have 'test_' in the filename. Since the test framework does not need to search for testcases, it will simply load any given testcase.

Example:

 test.php?class=atk.db.atkdb

Writing tests

See: Writing tests