Unittests

Bind server sockets to any free port

at 2010-02-01 in UnittestsEditorialAnnouncements by friebe

At the company I work for, we let the XP Framework's unittest run on various different machines, including Windows 2008 server and 32- as well as 64-bit Debian Linux boxes, with PHP versions ranging from 5.2.0 - 5.3.1 (lots of permutation, yes).

Hudson

On some of the newer machines we have configured Hudson to start multiple test runners at the same time. This lead to problems with the integration tests (for the FTP API, for example) where we actually fork off a standalone server in the background: The port in use was hardcoded. While this is perfectly OK normally, with mutiples suites executing simultaneously and trying to bind the same port, we were running into problems.


(more)

XP on a Mac

at 2010-01-24 in ReleasesUnittests by friebe

Continuing our series of trying to get the XP Framework run on as many platforms as possible, here's our newest achievement:

Screenshot

So far we have:
  • Windows: Windows XP, Windows 7, Windows Vista, Windows 2008 server
  • BSD: FreeBSD 5, 6 and 7
  • Linux: Gentoo, Ubuntu, Debian (3.1, 4.0, 5.0)
  • Mac: OS X 10
  • Other: Nokia 770
If you have XP running on a platform besides these, let us know and we'll add it here:-)



Continuous integration with Hudson

at 2009-10-02 in Unittests by friebe

The XP Framework's unittest suite has been extended by a new test listener which produces an XML file adequate for continuous integration systems. Test listeners receive events such as when as test run is started, a test succeeds, fails or is skipped and finally when the run is completed. In fact, the dots you see appearing on your console when running tests are implemented with a listener!

Here's what the Hudson dashboard looks like:

Hudson dashboard

To make the unittest command produce the XML files necessary to have Hudson render this overview, use the "-l" option:

$ unittest -l unittest.XmlTestListener hudson.xml [test [test [...]]]

Happy testing:)



RFC #0188: Test outcome

at 2009-09-28 in RFCsUnittests by friebe

Scope of Change
At the moment, there are three possible outcomes of a unittest: Succeeded, Skipped and Failed. This RFC suggests adding more kinds of outcomes: Error and NotRun.

Rationale
Be able to distinguish between the different non-success reasons.

Read the full RFC here



RFC #0187: @expect withMessage

at 2009-08-23 in RFCsUnittests by friebe

Scope of Change
The @expect annotation will be enhanced to provide a means for also checking the expected exception's message.

Rationale
Ensuring a certain exception message requires the "old-style" approach with try, fail(); and the checking the message inside catch (ExpectedException $expected), a construct we successfully removed the need for with @expect years ago.

Read the full RFC here



Discovering unittests

at 2009-06-01 in UnittestsExamples by friebe

In the api documentation of a class, certain tags can be used, such as @see, @param or @return. Not only can they be used but it's actually strongly encouraged (you knew that, though).

To discover unittests by a given class name, the doclet API can be used.


(more)

Feature showcase: Unittest & equality

at 2009-03-28 in Unittests by friebe

With the 5.7.2 release out, the unittest API now shows errors more concisely. Assume we have the following:

<?php 
$this->assertEquals(1, 1.0);
?>

Before, this used to show { expected: [1] but was: [1] } (this is because the AssertionFailedError class uses string casts). The new output now is { expected: [integer:1] but was: [double:1] }, which is positively better readable:-)



Heads up: Framework unittests

at 2009-03-27 in UnittestsAnnouncements by friebe

The archive xp-net.xp_framework-{VERSION}.xar, which contains the framework's unittests, has been removed from the boot classpath. It is no longer required for the XP runners (which is why it was originally there), classes used for these are all now in xp-tools-${VERSION}.xar.

To run unittests on a released version, use the following:

  $ unittest -cp {VERSION}/lib/xp-net.xp_framework-{VERSION}.xar [tests]

Example:
  $ unittest -cp 5.7.2/lib/xp-net.xp_framework-5.7.2.xar net.xp_framework.unittest.core.*



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



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
5.8-SERIES