|
From: Baumgartner M. <Mar...@sw...> - 2007-06-08 15:17:05
|
Hi all, I started an evaluation of mocking tools comparing rMock and jMock. What I have seen - and understood - so far is very interesting, but still little. Now we are trying to mock an object without a junit suite, that is without extending RMockTestCase The motivation is this:=20 the program is calling a backend system through a Connection-object. This 'border'-object we want to mock and then stuff it into objects using Connection via dependency injection MockConnection mockConnection implements IConnection Actor actor =3D new Actor(mockConnection); I found a Proxy class in your library, but no hint how to use it. I saw this was possible in jMock, so I guess this is possible with Rmock too. The next question is based on this:=20 When the backend system is changing, in particular the form or order of replies, we have to update the mock (otherwise we would mock 'the past'). Because there is a huge number of request/reply pairs, we must automate this. The idea is to have a switch like "record" that would write out the requests and its replies, from where we could generate a new Mock.=20 Did anybody try this and has a suggestion? Thanks for help Markus P.S. I googled the Internet for hours to find more documentation or examples, but didn't find anything. The documentation is addressing people that know a lot how the program works, but for newbies it is not suited (I learned how to mock with jMock documentation, which is not good as well , but a bit better. That's a pity because it does not ease the access to the tool. (I even started to write my own documentation including a testsuite with examples showing the different use cases and I guess such a suite with simple example might be handy for other users too. At least here it was...) Is there anybody out there, who has or found some more documentation? =20 =20 This message is for the named person's use only. It may contain = confidential, proprietary or legally privileged information. No = confidentiality or privilege is waived or lost by any mistransmission. = If you receive this message in error, please notify the sender urgently = and then immediately delete the message and any copies of it from your = system. Please also immediately destroy any hardcopies of the message. = You must not, directly or indirectly, use, disclose, distribute, print, = or copy any part of this message if you are not the intended recipient. = The sender's company reserves the right to monitor all e-mail = communications through their networks. Any views expressed in this = message are those of the individual sender, except where the message = states otherwise and the sender is authorised to state them to be the = views of the sender's company. |
|
From: Joakim O. <joa...@ag...> - 2007-06-08 19:51:52
|
Hi Markus, Thanks for your questions I feel I don't answer much but rather ask more questions. I try to communicate where I come from when reading your questions. I want to help but I fear I don't have much experience with what you want to do so I try to half tell you what I do and half comment on what I think can be done with RMock to meet your needs whether I believe it's a good idea or not. I hope this helps some and feel free to ask more. > I started an evaluation of mocking tools comparing rMock and jMock. What > I have seen - and understood - so far is very interesting, but still > little. Interesting, we would really like to know how the tool is perceived by others so if you want to share what you've found on the list or offline we would be very happy to hear about it. > > Now we are trying to mock an object without a junit suite, that is > without extending RMockTestCase > > The motivation is this: > > the program is calling a backend system through a Connection-object. > This 'border'-object we want to mock and then stuff it into objects > using Connection via dependency injection > > > MockConnection mockConnection implements IConnection > > Actor actor = new Actor(mockConnection); > >From that description and the code above I can not see why creating the mocks from a TestCase would be a problem. I'm sure I've missed something important such as what you are using to inject the dependencies. Personally I use RMock a bit inside out compared to what you want to do. I test interactions between objects "inside" the system instead of putting the mocks at the border of the system. This is what RMock was designed to do but that doesn't mean it cannot be used for other things. > > I found a Proxy class in your library, but no hint how to use it. I saw > this was possible in jMock, so I guess this is possible with Rmock too. > The proxy class is used behind the scenes in RMock, it's not intended to be used directly. Simply put, RMock does not support what you want to do in any simple way. We toyed around a bit with the framework for JUnit 4 wich by design sort of requires what you're requesting. We managed to do it but it required a bit of voodoo and quite frankly was a bit fragile (due to RMocks internal design centered around a hub) > > The next question is based on this: > > When the backend system is changing, in particular the form or order of > replies, we have to update the mock (otherwise we would mock 'the > past'). Because there is a huge number of request/reply pairs, we must > automate this. The idea is to have a switch like "record" that would > write out the requests and its replies, from where we could generate a > new Mock. > The order of calls should be unimportant unless you specify to use an ordered section. By using some obscure features in RMock (forEach(expression).in(all.methodsOf(class))... and a custom action that would print out the calls you could accomplish this. However, I think that rMock is the most useful when driving the design of units with TDD. I found that retrofitting RMock to test an already built system or testing something that is bigger than one or a few classes at a time tends to create more hedaches than be of help. We use as a rule of thumb that if you need more than 10 expectations to test something with rMock you're testing too much at the time. Sometimes that means breaking stuff up with the single responsibility principle as a guideline. Of course feel free to ignore this rule, the important thing is that your test communicates your intentions clearly and that you feel that RMock is a better choice than some other tool you can think of for the job. > Did anybody try this and has a suggestion? > > > Thanks for help > > Markus > > P.S. I googled the Internet for hours to find more documentation or > examples, but didn't find anything. The documentation is addressing > people that know a lot how the program works, but for newbies it is not > suited (I learned how to mock with jMock documentation, which is not > good as well , but a bit better. That's a pity because it does not ease > the access to the tool. (I even started to write my own documentation > including a testsuite with examples showing the different use cases and > I guess such a suite with simple example might be handy for other users > too. At least here it was...) > > Is there anybody out there, who has or found some more documentation? > Did you check out the users guide? http://rmock.sourceforge.net/documentation/docbook/pdf/rmock.pdf It is very reference oriented. Please share what type of documentation would help you get started and we will see what we can do (although we have had less time than we would have liked for RMock lately for private reasons mostly) > > This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. The sender's company reserves the right to monitor all e-mail communications through their networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of the sender's company. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Rmock-users mailing list > Rmo...@li... > https://lists.sourceforge.net/lists/listinfo/rmock-users > |