Unittests

RFC #0169: New package unittest.web

at 2008-08-14 in RFCsUnittests by friebe

Scope of Change
A new package unittest.web will be created. It will contain the base class WebTestCase with which web tests can be written.

Rationale
Integration testing.

Read the full RFC here



RFC #0150: Before and after methods for testcases

at 2008-01-06 in RFCsUnittests by friebe

Scope of Change
There will be a way to run methods prior to and after all tests in a TestCase class. In contrast to setUp() and tearDown() they will be run only once per class and not once per test.

Rationale
Initialize and dispose of resources that are expensive to create, e.g. a server instance, a network connection, ...

Read the full RFC here



Tracking SQL statements sent

at 2007-07-18 in UnittestsDatabases by friebe

The XP framework's RDBMS access API offers logging of SQL queries sent to the server by adding observers to database connections:

<?php 
// First, set up logger
Logger::getInstance
()->getCategory('sql')->addAppender(new ConsoleAppender());

// Retrieve connection and add the log observer for the "sql" category to the connection
$conn= DriverManager::getConnection('sybase://user:pass@dbserv01');
$conn->addObserver(LogObserver::instanceFor('sql'));
?>

Now SQL statements and other connection events will be logged to the console. For most purposes, this will suffice.

If you need to store all SQL statements sent to the server in an array, for example to assert on them in unittest environments, here's how:


(more)

New TestSuite::addTestClass()

at 2006-06-30 in Unittests by friebe

The util.profiling.unittest.TestSuite class features a new method called addTestClass() which makes it quite a bit easier to programmatically run TestCases.

Instead of having to loop through all methods using reflection, one can now simply call

<?php 
$suite->addTestClass(XPClass::forName('fully.qualified.ClassName'));
?>
- it'll take care of adding all methods annotated with @test to the suite.

Note: The old way of adding tests will still work!



508 Unit tests!

at 2006-06-30 in Unittests by friebe


Unittest run output for Fri Jun 30 17:55:37 CEST 2006
========================================================================
cli.ini : 5 tests, 5 succeeded, 0 failed, 0 skipped
collections.ini : 64 tests, 64 succeeded, 0 failed, 0 skipped
core.ini : 131 tests, 131 succeeded, 0 failed, 0 skipped
date.ini : 14 tests, 14 succeeded, 0 failed, 0 skipped
imaging.ini : 6 tests, 6 succeeded, 0 failed, 0 skipped
io.ini : 6 tests, 6 succeeded, 0 failed, 0 skipped
isbn.ini : 5 tests, 5 succeeded, 0 failed, 0 skipped
ldap.ini : 12 tests, 12 succeeded, 0 failed, 0 skipped
logging.ini : 14 tests, 14 succeeded, 0 failed, 0 skipped
rdbms.ini : 59 tests, 59 succeeded, 0 failed, 0 skipped
remote.ini : 34 tests, 34 succeeded, 0 failed, 0 skipped
security.ini : 1 tests, 1 succeeded, 0 failed, 0 skipped
string.ini : 4 tests, 4 succeeded, 0 failed, 0 skipped
types.ini : 8 tests, 8 succeeded, 0 failed, 0 skipped
unittest.ini : 29 tests, 29 succeeded, 0 failed, 0 skipped
util.ini : 34 tests, 34 succeeded, 0 failed, 0 skipped
webservices.ini : 44 tests, 44 succeeded, 0 failed, 0 skipped
workflow-casters.ini : 11 tests, 11 succeeded, 0 failed, 0 skipped
xml.ini : 27 tests, 27 succeeded, 0 failed, 0 skipped
This includes 29 unittest unittests (yes, the unit test API tests itself:))



RFC #0059: @timeout for unit tests

at 2006-06-15 in RFCsUnittests by friebe

Scope of Change
A timeout facility will be added to unit tests. When a test runs longer than the time span defined by the timeout facility, the test will be marked as timeouted.

Rationale
Integration tests that test certain system parts such as an LDAP server might want to test not only that accessing the server works but also that a query succeeds in a certain time.

Read the full RFC here



So You Wanna Write A Unit Test

at 2006-05-20 in UnittestsFurther reading by friebe

Stumbled upon this while surfing around the blogosphere:
Five things to keep in mind while you are trying to work up the ambition to write that test:

  1. Don't take all day
  2. Silence, please
  3. Skip catching exceptions
  4. Don't write the War And Peace of test methods
  5. Don't give up!
The original article is at Russ Olsen's Weblog



Code coverage

at 2006-05-12 in UnittestsExperiments by friebe

The XP framework's unittesting API has been experimentally extended by a userland code coverage implementation. For an example of a generated code coverage for the util.Binford class, have a look here.


(more)

SOAP, RPC and JSON unittests

at 2006-05-07 in Unittests by friebe

The unittests from the RPC package, the JSON package and the SOAP package were merged into a new collection of webservices tests, webservices.ini. Together they form 43 tests.



XP Core: 100 Unittests and counting!

at 2006-05-06 in AnnouncementsHomepageUnittests by friebe

Results for test suite run at Sun, 07 May 2006 13:31:22 +0200: 107 tests, 107 succeeded, 0 failed, 0 skipped

We started developing unittests to ensure the XP framework's core components' functionality a while ago and have continued doing so. With the implementation of RFC #0055 (new xp::stringOf()) the number of core tests has now exceeded one hundred!


(more)

Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases