Happy !

zeroflag / growing-oo-software-in-smalltalk

Project infos

License MIT
Tags test, goos, tdd, mock
Creation date 2012-11-25
Website

Monticello registration

About growing-oo-software-in-smalltalk

The Growing Object-Oriented Software Guided by Tests Example Code ported to Pharo Smalltalk

This is the Smalltalk translation of the example code from the book called Growing Object-Oriented Software Guided by Tests.

The main difference between the original and the Smalltalk version, is that this one uses IRC protocol instead of XMPP. But you don't need to setup your own local IRC server, because the tests use a public server (irc.freenode.net). The nick and chan names are randomly generated which helps avoiding collision.

The commit history follows the chapters in the book:

  • Single item-join, lose without bidding
  • Single item-join, bid & lose
  • Single item-join, bid & win
  • Single item-show price details
  • Multiple items
  • Add new items through the GUI
  • Stop bidding at stop price
  • Translator - invalid message from Auction

Installation

The project can be loaded to Pharo with the following script:

Gofer new
    smalltalkhubUser: 'zeroflag' project: 'growing-oo-software-in-smalltalk';
    package: 'ConfigurationOfAuctionSniper';
    load.

((Smalltalk at: #ConfigurationOfAuctionSniper) project version: '2.0') load.

Note: Since 2.0 the version, the tests use BabyMock2, and they require Pharo 3.0 at least.

Notes on the unit tests

The unit tests use BabyMock with visual mode turned on. You can run them either from the browser or using the test runner.

Notes on the end to end tests

The end to end tests use an IRC client and connect to irc.freenode.net:6667. This takes some time. Running the end to end tests from the test runner will block the user interface for several seconds and you won't see anything about the auction. If you want to see the Sniper window you can start the test as follow:

[ AuctionSniperEndToEndTest run: #testThatSniperJoinsAuctionUntilAuctionCloses ] fork

Or you can run all end to end tests in the background by executing:

AuctionSniperEndToEndTest forkAll

Notes on the code

The code is very similar to the GOOS version, but there are minor differences. Some places I use announcers where the original code relies on listeners. The Smalltalk version uses Morphic instead of Swing. The Main class looks silly in a Smalltalk image, but I didn't want to change the original concept, so I kept it. In Smalltalk, the interfaces are not so explicit like in Java, so you won't find the AuctionEventListener. Instead of explicit interfaces, I use protocol names (method categories) with the name matches to the name of the Java interface. So in the AuctionSniper class, there will be a protocol named "auction event listener" containing the appropriate methods.

If you have any questions feel free to tweet or email me.

Attila Magyar