Jmock Présentation Et Tutorial

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

Icare Design 2009

Icare Design 2009

Jmock, outils et astuces

Mohammed Boukoutaya

Alcatel-Lucent Services for Enterprise All Rights Reserved © Alcatel-Lucent 2007


Plan

1. Les prérequis
2. La philosophie
3. L’utilisation de Jmock

All Rights Reserved © Alcatel-Lucent 2007


Icare Design 2009

Les prérequis

Alcatel-Lucent Services for Enterprise All Rights Reserved © Alcatel-Lucent 2007


 IDE : eclipse.
 JDK 1.6 ou autre
 La JavaDoc de Jmock
 La bibliothèque Jmock 2.5.1

All Rights Reserved © Alcatel-Lucent 2007


La philosophie

5 | Presentation Title | Month 2007 All Rights Reserved © Alcatel-Lucent 2007


La philosphie

All Rights Reserved © Alcatel-Lucent 2007


La philosphie

 Les généralité d’utilisation

 Accès complexe,
 DataBase,
 Utilisation de bibliothèques tierces

All Rights Reserved © Alcatel-Lucent 2007


L’utilisation

8 | Presentation Title | Month 2007 All Rights Reserved © Alcatel-Lucent 2007


Utilisation

The invocation is expected once and once only.


one

exactly(n).of The invocation is expected exactly n times. Note: one is a convenient shorthand for exactly(1).

atLeast(n).of The invocation is expected at least n times.

atMost(n).of The invocation is expected at most n times.

between(min, max The invocation is expected at least min times and at most max times.
).of

allowing The invocation is allowed any number of times but does not have to happen.

The same as allowing. Allowing or ignoring should be chosen to make the test code
ignoring clearly express intent.
never The invocation is not expected at all. This is used to mak

All Rights Reserved © Alcatel-Lucent 2007


Utilisation

context = new Mockery() { {

setImposteriser(ClassImposteriser.INSTANCE);

};

final SearchUdaService searchUdaMock = context.mock(SearchUdaService.class);

context.checking(new Expectations() {

one(mockStub).searchByFullName(with(any(SearchByFullNameRequest.class)));

will(returnValue(searchByFullNameResponse));

});

All Rights Reserved © Alcatel-Lucent 2007


www.alcatel-lucent.com

11 | Presentation Title | Month 2007 All Rights Reserved © Alcatel-Lucent 2007

You might also like