Use JUnit to test EditContactPresenter
- Checkout the following as a maven project (or switch to tag): https://gibb.myversioncontrol.com/subversion/mvp_contacts/tags/1.5.testing-lab/ (user/pass: training/training)
- You will
- Test that all contact fields are not empty before they are saved
- All this will be done in the contacts-web project
TDD: Test field validation rules
- Open EditPresenterTest.java
- Edit testSaveButton
- Set presenter.contact to an empty ContactDto
- Mock display methods getFirstName and getLastName to return HasValues that contain non-empty strings (Hint: use StringValue class for andReturn method)
- Mock display method getEmailAddress to return a HasValue that contains null (Hint: use StringValue class for andReturn method)
- Run as JUnit test: it should fail with an AssertionError: Unexpected method call send(...)
- Fix EditContactPresenter.doSave() to validate not empty values
- Rerun test, should succeed
- What could we assert at the end of testSaveButton?
This page was last modified on 11 June 2010, at 08:10.