Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.37 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class A
  2. {
  3.         B b;
  4.        
  5.         public B getB()
  6.         {
  7.                 return b;
  8.         }
  9.  
  10.  
  11.  
  12.         public setB(B b)
  13.         {
  14.                 this.b=b;
  15.         }
  16.  
  17.         public String  method(parameter)     //method of class A
  18.         {
  19.                 String str = b.method2();
  20.                 return str;
  21.  
  22.         }
  23.  
  24. }
  25.  
  26. class YourTest
  27. {
  28.    public void testMethodShouldReturnExpectedString()
  29.  {
  30.      
  31.      A a = new A();
  32.      B b = mock(B.class);
  33.      a.setB(b);
  34.      a.method(parameter);
  35.  }
  36.  
  37. }