FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Up and coming: selfmock

 
Post new topic   Reply to topic     Forum Index -> DMocks
View previous topic :: View next topic  
Author Message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Fri Mar 21, 2008 12:57 pm    Post subject: Up and coming: selfmock Reply with quote

Dmocks is unfortunately hampered by problems with dmd2's stability. However, that's a problem only with automatically generating a mock class automatically. Granted, it's a lot more painful to do that by hand, but it's at least possible. And it doesn't depend on getting around ugly compiler bugs nearly as much.

So, I'm cannibalizing dmocks to create selfmock. It'll support dmd1 and Tango, and it'll require you to create each mocked class manually. This should be mostly painless; in the general case, it should look a bit like this:

Code:

class MockMyInterface : Mocked, IMyInterface
{
    mixin(method!(&IMyInterface.method1));
    mixin(method!(&IMyInterface.method2));
}

class MyTests : TestFixture
{
    private static IMyInterface _myInterface;
    private static Mocker _mocks;
    override void setup()
    {
        _myInterface = new MockMyInterface();
        _mocks = new Mocker();
        _mocks.register(_myInterface);
    }
    // ...
}


If you're using interfaces, it should roughly double the amount of work you do in extracting an interface. Annoying, but better than nothing. There are the typical issues with overloaded methods, of course.

Once dmd2 is stable and supports Tango, it'll be a relatively minor matter for me to add support for automocking and for client code to convert to it.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DMocks All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group