From: brett l. <bre...@gm...> - 2012-06-06 17:07:03
|
I have no objections to Mockito. One thing I'd like to see is just a central mocked data set that we can use for exercising the code. Eventually, it would be nice to grow our test case coverage. ---Brett. On Wed, Jun 6, 2012 at 12:33 PM, Stefan Frey <ste...@we...> wrote: > Erik & Brett: > recently I have mailed that I would like to add a mock library to > support testing. At that time I preferred JMock (mostly above EasyMock). > However I did reevaluate my choice again and realized that the library > that suited my tastes best is Mockito. > see http://code.google.com/p/mockito/ > > Checkout the documentation at > http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html > which really shows very well the very simple but powerful style used. > > Or compare to the first test example which I have pushed to the rails2.0 > branch (ActionChangeTest.java) in the junit folder with the identical > hierachy as rails below (the source code itself is under src folder). > > It is really easy to create mock objects by simply annotate private > fields in the test classes with @Mock > or directly with Player player = mock(Player.class) > > Verifying that a method of the mock is called (once) requires: > verify(mock).method() > > And stubbing a method of the mock is initialized with: > when(mock.method()).thenReturn(value) > > Avoiding using strings also ensures that autocompletion of Eclipse-IDe > still works. > > This syntactical sugar simplifies unit tests substantially (at least in > my opinion). > > Stefan > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel |