Skip to content

helmedeiros/TestingBehaviorThroughMocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestingBehaviorThroughMocks

Testing behavior through mock objects — part two of a three-part TDD exercise series, built around Caelum/Alura's PM-72 course.

Where part one covered plain unit tests, this step introduces test doubles: when collaborators (DAOs, mail senders, payment gateways) make a system costly to test directly, mocks let you simulate and verify the expected interactions.

Domain

Type Role
Auction, Bid, User, Payment The auction domain model.
Auctioneer Evaluates auctions.
AuctionCloser Closes auctions older than a week.
PaymentManager Generates payments for closed auctions.
infra/ (MailSender, AuctionDao, repositories) Collaborators to mock.

The exercise

Write AuctionCloserTest so it proves the closer shuts auctions started over a week ago — by mocking the DAO and injecting it through the constructor. Build up from there.

Build & test

mvn test

Part one: UnitTestingFirstSteps. Part three: TestingWebApplicationWithSelenium.

License

MIT

About

Part two of a TDD-learning series: test behavior with mock objects (Caelum/Alura PM-72).

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages