I'm following the book "Growing Object-Oriented Software Guided by Tests"... and I've hit a thorny patch.
Rather than using Hamcrest and jMock (authors' choice) I'm using AssertJ and Mockito.
But I'm also using their chosen Swing testing framework, WindowLicker from objogate.com.
An example of a bit of test code that is currently failing is this:
JTableDriver td = new JTableDriver( this );
td.hasRow( matching( withLabelText( itemId), withLabelText( String.valueOf( lastPrice )),
withLabelText( String.valueOf( lastBid )), withLabelText( statusText )));
... at the moment I know the JTable consists of one row (or it might just possibly be zero rows, but the failure message doesn't suggest this). So one might hope it would be fairly straightforward to incorporate the values found in row 0 in a custom failure message. Unlike AssertJ, where I found an answer to making custom failure messages here, I can't see any way of doing this. The return value from hasRow is void, for example. The return from matching is static<any>, which as a newbie with these frameworks I'm struggling to understand.
It even appears to be very tricky/impossible to get hold of the JTable object from JTableDriver, so I'm a bit stuck: JTableDriver.component().component() may be the way to do it, but in this context this is actually throwing an OutOfBoundsException, so this appears not the right way to go about things.
Ah... there is no SO tag for WindowLicker I see... hmmmm.
Aucun commentaire:
Enregistrer un commentaire