Test-driven development with Java Edouard SWIAC Java Lab SF - email@example.com
Summary• Principles• Mocks and stubs• TDD example
repeittion of very What is TDD ?short dev cycle of 3stepstest come from storyrefactorchanging sourcewithout modifyingexternal functional Software development process in 3 stepsbehavior
because you have to design thecomponent before you code, TDD in shortand note design the componentwhile you code • Encourages simple design (Ken Beck) • Relies on automated unit testing • Builds a harness against software regression
although required,dependencies and Testing and collaboratorscollaborators needs to bereplace by somethin • Testing a unit of code is not testing its collaborators • Collaborators have to be reproduced and controlled to produce expected results so tests can run => enter mocks !
Stubs and mocks stub on existing code or yet to be code mock help to test behavior• A stub (or method stub) returns programmed results when called• A mock (or mock object) mimics a real object. It has the same interface as the real objects it mimics.• Mocks methods can be stubbed