Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] First Test with JMock

bekeffy zoltan

2008-07-10

Replies: Find Java Web Hosting

Author LoginPost Reply
hello there

I'm trying to make a first little program with JMock work
but cannot make it, so I searching for some help

here is my code, could someone explain what's wrong with it?

in fact, the test succeed every time I launch it, yet it shoudnt as I have a
change in the Math class, so it should fail as it isnt anymore an addition

thanks in advance

package test.jmock;

public class Math {

 public int doCalculation(int a, int b){

  return a-b;

 }
}

package test.jmock;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;
import org.junit.runner.RunWith;


@RunWith(JMock.class)
public class FirstJMock {
 
 Mockery context = new
JUnit4Mockery(){{setImposteriser(ClassImposteriser.INSTANCE); }};
  Math mockUpdate = context.mock(Math.class);
   
  @Test
 public void doMathTest() {
   
   context.checking(new Expectations() {{
       one (mockUpdate).doCalculation(4, 3); will(returnValue(7));
     }});
     
    mockUpdate.doCalculation(4, 3);
     
 context.assertIsSatisfied();
   
  }
}



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.