views:

240

answers:

2
+2  Q: 

Delphi Mock Wizard

Let me preface this by saying I'm fairly new to Unit Testing, Mocks, Stubs, Etc...

I've installed Delphi-Mock-Wizard. When I select a unit and "Generate Mock", a new unit is created but it's very basic and not anything what I understand Mocks to be.

 unit Unit1; 

(** WARNING - AUTO-GENERATED MOCK! Change this unit if you want to, but be aware that any changes you make will be lost if you regenerate the mock object (for instance, if the interface changes).

My advice is to create a descendent class of your auto-generated mock - in a different unit - and override things there. That way you get to keep them.

Also, the auto-generate code is not yet smart enough to generate stubs for inherited interfaces. In that case, change your mock declaration to inherit from a mock implementation that implements the missing interface. This,
unfortunately, is a violation of the directive above. I'm working on it.
You may also need to manually change the unit name, above. Another thing
I am working on. **)

 interface

 uses
   PascalMock,   
   TestInterfaces; 

 type   
   IThingy = interface; 

 implementation 

 end.

Looking at the source there seems to be quite a bit commented out. I'm wondering, has anyone gotten this to work?

My IDE is D2010.

Thanks.

+5  A: 

The Delphi Mock Wizard is not finished. It's barely even functional. The output you posted in your question looks like the only thing that tool is capable of generating. If you want to use it, you'll have to wait until it matures. Since it was last updated in October 2008, you might have to wait a long, long time.

You'll have to choose a different direction for your mocking needs. Please see an earlier Stack Overflow question for advice:

What is your favorite Delphi mocking library?

Rob Kennedy
A: 

Unfortunately, this is what I thought. Yes, I saw the earlier question and in fact that's how I discovered Delphi-Mock-Wizard.

Thanks.

Todd
Welcome to Stack Overflow. What you've posted here wasn't really an *answer* to your question. This section is only for answers. You can use the "add comment" button for things like this. Furthermore, if you're satisfied that my answer has fully addressed your question, you can click the check-box button next to it to "accept" it. That's optional, but if you ask more questions here, some people will look at your low accept rate and refuse to answer any more.
Rob Kennedy