LDSTechForumProjects

Beyond MVP Lab 3

Use JUnit to test EditContactPresenter

  1. 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)
  2. You will
    1. Test that all contact fields are not empty before they are saved
    2. All this will be done in the contacts-web project

TDD: Test field validation rules

  1. Open EditPresenterTest.java
  2. Edit testSaveButton
  3. Set presenter.contact to an empty ContactDto
  4. Mock display methods getFirstName and getLastName to return HasValues that contain non-empty strings (Hint: use StringValue class for andReturn method)
  5. Mock display method getEmailAddress to return a HasValue that contains null (Hint: use StringValue class for andReturn method)
  6. Run as JUnit test: it should fail with an AssertionError: Unexpected method call send(...)
  7. Fix EditContactPresenter.doSave() to validate not empty values
  8. Rerun test, should succeed
  9. What could we assert at the end of testSaveButton?
This page was last modified on 11 June 2010, at 09:10.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.