100 likes | 280 Views
Rhino Mocks 3.5. Oren Eini / Ayende Rahien ayende@ayende.com http://www.ayende.com/Blog/. Standard Testing. [Test] public void TwoPlusTwo_Equal_Four () { var result = new Calculator().Add(2,2) Assert.AreEqual (4, result, “Math is broken” ); }. We aren’t writing calculators.
E N D
Rhino Mocks 3.5 Oren Eini / AyendeRahien ayende@ayende.com http://www.ayende.com/Blog/
Standard Testing [Test] public void TwoPlusTwo_Equal_Four() { var result = new Calculator().Add(2,2) Assert.AreEqual(4, result, “Math is broken”); }
Interactions • No state to test? • ExecuteCommand • SendSms • Complex collaborations • Get user from repository, if has phone, send SMS, otherwise, log error and send email.
Objects don’t work in isolation But we want to test them this way
A bit of history • When testing, we want: • Arrange • Act • Assert • When mocking, we had to: • Expect • Act • Verify • Not anymore
People, I need a scenario… • And let us make it a real one. • I am tired of writing calculators and bowling games
A few words of caution Avoid over specified tests Test only one thing Use Inversion of Control Container and Auto Mocking Container when complexity grows.