Unittests

XP Compiler on Travis

at 2013-05-05 in UnittestsLanguage by friebe

TravisOn a short note: Just like any part of XP Technologies, the XP Language and its compiler are unittested. And since today, these tests are also run on Travis-CI.



RFC #0267: Unittest parameterization

at 2013-04-01 in UnittestsRFCs by friebe

Scope of Change
This will extend the unittest API by adding a facility for providing values to a test.

Rationale
This will make it easier to discover problems in tests written using foreach loops currently, and at the same time reduce the amount of code that needs to be written for tests with separate test methods for every value.

Read the full RFC here.



Ubuntu users: Heads up!

at 2012-09-04 in AnnouncementsUnittests by friebe

If you recently updated your runners using the xprt-update.sh script distributed alongside them, you would start receiving errors such as

  ./unittest: 99: ./unittest: Bad substitution
on certain platforms (this included our Travis CI build, which was broken today because of this). We could verify this would happen on two separate Ubuntu instances. The problem was that we were using the string-replace feature not supported by "pure" shell - ${string//substring/replacement} - we'd tested on Windows / Cygwin and Gentoo installations before releasing, but both symlink /bin/sh with /bin/bash, while Ubuntu (and probably also others) don't.

A fix for this was committed and a new version was released. To update your runners, use the manual way (the update script mentioned above relies on functioning xp runners):

  $ cd /path/to/xp/runners
$ wget http://releases.xp-framework.net/setup/bin -O - | php
This will overwrite the runners with the newer versions.



5.8.6-RELEASE: Unittests

at 2012-07-09 in ReleasesUnittestsAnnouncements5.8-SERIES by friebe

The XP Group is proud to announce the immediate availability of the XP Framework release 5.8.6. This release has focussed on improving the unittests APIs:

  • We have improved unittest's error messages as described in RFC #0256 as well as for large strings
  • Tests can now be skipped from within themselves by calling $this->skip($reason)
  • Multiple @beforeClass / @afterClass methods are now allowed - see RFC #0255.
  • Unittest output is colored if a capable terminal window is detected
  • The unittest command line runner now accepts file system paths in its argument list and will run all tests inside it
But that's not all - the detailled ChangeLog can be seen here.

Go get it!
  $ cd ~/xp
$ wget http://releases.xp-framework.net/setup/5.8.6 -O - | php -- -d ~/bin/

Enjoy:-)



Surpassed 5000 unittests

at 2012-07-07 in Unittests by friebe

On a short note: The XP Framework's core now surpassed 5000 unittests:

  $ unittest src/test/resources/*ini
[...]
OK: 5177/5450 run (273 skipped), 5177 succeeded, 0 failed
Memory used: 42736.45 kB (50112.08 kB peak)
Time taken: 14.374 seconds
Although can never have enough tests, this is a tenfold compared to a couple of years ago, when we had reached 500+:-)



"Infinitest" with the XP Framework

at 2012-06-30 in Unittests by friebe

Thinking about our upcoming 5.8.6 release whose focus is on unittesting, I recently came up with the idea to have unittests run whenever I change, and save, the code I'm working on (yesterday evening I found out in the Java world this is called "infinitest" - my focus though was to get this done on the command line, without the necessity to plug in to various IDEs).

Searching for utilities to monitor the file system for changes, I found the "inotify tools". Since I work on Windows using Cygwin though, I decided to "port" them using the .NET Framework's FileSystemWatcher class. The results can be found here (just clone and run "make" - prerequisites are .NET Framework v3.5).

Given this, the basic command line is:

  $ inotifywait -r -m src/ | while read line ; do \
# The action to be executed when files are modified inside the "src"
# directory or any of its subdirectories
done

Extending this example to run unittests is easy, especially with unittest now accepting paths as command line argument. Last but not least, we use an additional listener to update the xterm or xterm compatible shell's title with the progress and the "executive summary" later on, so we only have to glance at the console's title bar to see what's going on.

Screenshot
infinittest for XP running in a mintty window

Putting it all together, we now end up with the following command line:
  $ inotifywait -r -m src/ | while read line ; do \
unittest -l xp.unittest.XtermTitleListener - src/ ; \
done

Pretty cool, I'd say!:-)



RFC #0255: Allow multiple @beforeClass / @afterClass methods

at 2012-06-30 in RFCsUnittests by friebe

Scope of Change
The unittest runner will support running multiple @beforeClass / @afterClass methods.

Rationale
Greater flexibility

Read the full RFC here



Continuous integration in the cloud

at 2012-05-09 in AnnouncementsUnittests by friebe

Travis CI LogoThanks to Alex we're now integrated with Travis CI!

To learn more about Travis CI, visit their about page.



5.8.4-RELEASE: Multiple config sources, selectable database drivers, SQLite3, MySQL local sockets, mocking library

at 2012-02-26 in ReleasesUnittestsDatabasesAnnouncements5.8-SERIES by friebe

The XP group is proud to announce the immediate availability of framework release 5.8.4. After four release candidates and about three and a half months, we deliver a bigger release, including the following:

Multiple config sources
This feature described in RFC #0221 enables combining properties from more than one source (e.g., ini-files). For example, one can now have a global, system-wide configuration and extend on that in your application. This feature is supported by "XPCLI" commands and the web runner - details can be found here.

Selectable database drivers
With more and more database protocols appearing as userland implementation (MySQL, Sybase, MSSQL), the urge to be able to chose between drivers has come up; and be it just for testing. To select a specific driver, append the implementation name to the driver, e.g. mysql+std to select ext/mysql. To retrieve the default MySQL driver, one can still use mysql://user@host DSN syntax.

SQLite3
With the deprecation of SQLIte2 in PHP 5.4, we have decided to implement SQLIte3 support in the XP Framework. At the same time, and because we now offer selectable drivers, the default is SQLIte3.

MySQL local sockets
We now support local socket connectivity in our MySQL driver implementation by using the special hostname ".": By using "mysql://./DATABASE", we connect through a local socket, while "mysql://localhost/DATABASE" uses TCP/IP. This has been unified throughout the various MySQL drivers.

Mocking library
The package unittest.mock contains the all-new mocking library. The API is modeled in a fashion similar to EasyMock (Java), Rhino Mocks (.Net). You can read all about the details in RFC #219.

...and more
We have almost 20 bugfixes and various features included in this release - all of which can be seen in the ChangeLog.



Go get it!
  $ cd ~/xp
$ wget http://releases.xp-framework.net/setup/5.8.4 -O - | php -- -d ~/bin/

Enjoy:-)



Overwriting Testcase's special methods

at 2011-03-21 in UnittestsAnnouncements by friebe

A fix has been committed to the unittest API that prevents (accidentally) overwriting special methods from unittest.TestCase. What had happened is the following:

  class SystemPropertyTest extends TestCase {

#[@test]
public function getName() {
$this->assertEquals('...', $this->fixture->getName());
}
}

As the XP Framework doesn't require a "test" prefix on the method names, it has become common practice to name the test methods after the methods they're testing, usually appending or prepending the variant (e.g. "singleAddItem" and "multipleAddItem"); in this case there was no variation and thus the simple name.

Unintentionally, this was now overwriting the unittest.TestCase::getName() method, which in turn was creating faulty output when rendering the test result. If you made the above testcase fail, the test runner would even raise an uncaught exception and not report any results at all.

This has now been fixed; and the erroneous overwriting will be reported early along as lang.IllegalStateException: Cannot override unittest.TestCase::getName with test method in com.example.unittest.systems.SystemPropertyTest.



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
Unicode
Language
5.9-SERIES