infinite / mockito-flex

0 stars 0 forks source link

MockitoRule: avoid Mock(type="myPackage.MyClass") #39

Open infinite opened 10 years ago

infinite commented 10 years ago

with mockito:

// [Rule]

// public var includeMocks:MockitoRule = new MockitoRule();

// [Mock(type="myPackage.MyClass")]

// public var m:MyClass;

with asmock:

// [Rule]

// public var includeMocks:IncludeMocksRule = new IncludeMocksRule([MyClass]);

// public var m:MyClass;

Could we use the asmock way to build the MockitoRule? So we may have:

public var includeMocks:MockitoRule = new MockitoRule([MyClass]);

I would like to avoid type="myPackage.MyClass" (which is problematic when we move a class to another package / rename a class ...)

infinite commented 10 years ago

From loomis on 2011-11-08 16:08:25+00:00

Hmm - you don't have to provide type argument if the variable type is what you expect. So you can do:

[Mock]

public var m:MyClass;

And this will work perfectly fine. You may however need to provide other types if you are subclassing.

Could you please verify if it works for you?

infinite commented 10 years ago

From Anonymous on 2011-11-08 16:45:32+00:00

You're right! It's working fine

I was doing like the sample :

// [Mock(type="com.acme.TestClass")]//

// public var mockie:TestClass;//

So I thought it was mandatory...

Problem solved

Thanks

infinite commented 10 years ago

From loomis on 2011-11-08 17:38:16+00:00

Cool!