Skip to content
stephanenicolas edited this page Sep 13, 2013 · 4 revisions

BoundBox provides access to all fields defined in a given class.


Let's say we have a class A like :

@SuppressWarnings("unused")
public class A {
 private String foo = "bb";
}

With BoundBox, you can write a test that accesses fields of A :

public class ATest {
 @BoundBox( boundClass = A.class )
 private BoundBoxOfA boundBoxOfA;
 
 @Before
 public void setUp() {
   boundBoxOfA = new BoundBoxOfA( new A() );
 }
 
 @Test
 public void testFieldRead() {
   //GIVEN
   //WHEN
   //THEN
   assertEquals( "bb", boundBoxOfA.boundBox_getFoo());
 }

 @Test
 public void testFieldWrite() {
   //GIVEN
   //WHEN
   boundBoxOfA.boundBox_setFoo("cc");
   //THEN
   assertEquals( "cc", boundBoxOfA.boundBox_getFoo());
 }
}

For all fields defined in a class A, its BoundBox will contain setters and getters prefixed with boundBox_. This allows to avoid collisions with the setters and getters defined in A itself.