由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - jmock ?? or any other mocking tools?
相关主题
SCJP Books在AWS如何作测试
maybe useful SCJP-mock exam link listcan applet implements runnable?
考SCEA归来问一个特别土的问题
where to get mock? Re: 考SCEA归来Timer and TimerTask
A question on easyMock2jvm是怎么implement monitor的?
Does anyone know where to get SCJP mock-exam?interface和implementation class
EasyMock 真的有用么?Re: Question: Java Synchronization
what is really hard is testingbasic java question
相关话题的讨论汇总
话题: myclass话题: jmock话题: mock话题: createxxx
进入Java版参与讨论
1 (共1页)
c******n
发帖数: 4965
1
the nasty thing about jmock is that whenever I want to mock a dependent
object, I have to abstract out the object creation,
and turn a statment like
MyClass obj = new MyClass();
into
MyClass obj = createMyClass();
while production code has
MyClass createMyClass() { return new MyClass();}
and mock code has
MyClass createMyClass() { return instance_var_mock_myclass;}
I end up having a lot of createXXX() methods in each class implemented,
furthermore, clover would complain that the createXXX() them
S********a
发帖数: 1163
2
lots of mockup tools.
we also use mokito and easymock as well.

【在 c******n 的大作中提到】
: the nasty thing about jmock is that whenever I want to mock a dependent
: object, I have to abstract out the object creation,
: and turn a statment like
: MyClass obj = new MyClass();
: into
: MyClass obj = createMyClass();
: while production code has
: MyClass createMyClass() { return new MyClass();}
: and mock code has
: MyClass createMyClass() { return instance_var_mock_myclass;}

m******t
发帖数: 2416
3
JMock is best used to mock interfaces, i.e., where you would inject
implementations
instead of hardcoded new SomeClass(). In the latter case the two classes
are probably
too tightly coupled to be tested separately anyway.

【在 c******n 的大作中提到】
: the nasty thing about jmock is that whenever I want to mock a dependent
: object, I have to abstract out the object creation,
: and turn a statment like
: MyClass obj = new MyClass();
: into
: MyClass obj = createMyClass();
: while production code has
: MyClass createMyClass() { return new MyClass();}
: and mock code has
: MyClass createMyClass() { return instance_var_mock_myclass;}

1 (共1页)
进入Java版参与讨论
相关主题
basic java questionA question on easyMock2
ant junit and log4j can't work togetherDoes anyone know where to get SCJP mock-exam?
structure in Java??EasyMock 真的有用么?
库里有一个函数名也叫Timewhat is really hard is testing
SCJP Books在AWS如何作测试
maybe useful SCJP-mock exam link listcan applet implements runnable?
考SCEA归来问一个特别土的问题
where to get mock? Re: 考SCEA归来Timer and TimerTask
相关话题的讨论汇总
话题: myclass话题: jmock话题: mock话题: createxxx