Example /// pseudo code for CheckAuthentication /// input: string id /// input: string password /// output: true --> if pass the checking /// false --> else fail the checking /// get the passwords hash result from DAO AccountDAO dao = new AccountDao(); String passwordHashFromDAO = mDao.getPasswordHash(id); mLog.writeLog(passwordHashFromDAO ); /// get the ids hash result from Hash Hash hash = new Hash(); String hashResult = mHash.getHashResult(password); mLog.writeLoghashResult (); /// check the result return passwordHashFromDAO.equals(hashResult);
Example -- Dummy• Dummy Object o Passed around but never actually used. Usually, they are just used to fill parameter list.
Example -- Stub• Stub o Provide canned answers to calls made during the test, usually not responding at all to anything outside whats programmed in for the test.
Example -- Fake• Fake o Actually have working implementations, but usually take some shortcut which makes them not suitable for production.
Example -- Spy• Spy o Stubs that also record some information based on how they were called. One form of this might be an email service that records how many messages it was sent.
Example -- Mock• Mock o pre-programmed with expectations which form a specification of the calls they are expected to receive. They can throw an exception if they receive a call they dont expect and are checked during verification to ensure they got all the calls they were expecting.