On Tue, 23 Sep 2008, Emanuele Gesuato wrote:
> I'm writing a testcase in which i try to compare the value of a 
> textfield in a form with the value of a pojo.
> 
> This value is a BigDecimal.
> 
> This is the code:
> FormTester ft = 
> tester.newFormTester(GestisciListino.tags.pizzaForm.toString());
> assertEquals(pizza.getPrezzo().toString(), 
> ft.getTextComponentValue(Pizza.CAMPO_PREZZO));
> 
> if the BigDecimal is "5.00", 
> ft.getTextComponentValue(Pizza.CAMPO_PREZZO) is "5", and the assertion 
> fails. But if i try to use the form using the browser the value setted 
> in the form is correctly "5.00". Why this difference ? I'm expecting 
> that the value retrieved using ft.getTextComponentValue has to be equals 
> with the value displayed by the browser. Am i missing something ?

What are you trying to test actually? The test seems to just 
check that the raw input object would match to the input you 
just fed, no? Normally with FormTester it makes more sense to 
submit the form and see how some interesting values of your 
domain objects get updated or something like that. 

Anyway, the discrepancy you're seeing might be because of 
how BigDecimal gets converted by Wicket. But I wouldn't worry
about fixing that unless it becomes a problem in a meaningful
test.

Also, Money class would be a lot better for handling money 
than BigDecimal :)

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to