Hi!
I am trying out testing views in JRE JUnit tests folowing
http://arcbees.wordpress.com/2010/11/25/testing-views-using-gwt-platform-mockingbinder/
article.
My view implements TakesValue<MeetingEventProxy> and is something like
this:
1. public class EventView extends Composite implements
2. TakesValue<MeetingEventProxy>, IsWidget {
3. public interface Binder extends UiBinder<Widget, EventView> {
4. }
5.
6. private MeetingEventProxy meetingEvent;
7.
8. @UiField
9. Label date <http://www.php.net/date>;
10. @UiField
11. Label startTime;
12.
13. @Inject
14. public EventView(final Binder uiBinder) {
15. initWidget(uiBinder.createAndBindUi(this));
16. }
17.
18. @Override
19. public void setValue(MeetingEventProxy meetingEvent) {
20. this.meetingEvent = meetingEvent;
21.
22. date <http://www.php.net/date>.setText(renderValueOrBlank(
meetingEvent.getDate <http://www.php.net/getdate>()));
23. startTime.setText(renderValueOrBlank(meetingEvent.
getStartTime()));
24. }
25.
26. private String renderValueOrBlank(Object value) {
27. return value == null ? "" : String.valueOf(value);
28. }
29.
30. @Override
31. public MeetingEventProxy getValue() {
32. return meetingEvent;
33. }
34. }
For example, I want to test if values set in view are formated correctly .
1. @Test
2. public void shouldShowEventDateInCorrectFormat(MeetingEventProxy
event) {
3. given(event.getDate <http://www.php.net/getdate>()).willReturn
(new DateTime("2011-05-15").toDate());
4.
5. eventView.setValue(event);
6.
7. verify(eventView.date <http://www.php.net/date>).setText(
"15.05.2011");
8. }
For now I used mock of MeetingEventProxy , but value objects doesn't get
mocked.
*Should I use AutoBeanFactoryMagic to setup fixture?*
*
*
AutoBean<MeetingEventProxy> meetingEvent= AutoBeanFactoryMagic.createBean(
MeetingEventProxy.class, new Configuration.Builder().build());
*Should it be tested in some other place? *
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.