beehive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jason knox <>
Subject RE: testing controls
Date Thu, 30 Aug 2007 15:47:26 GMT
   Hi Chris --
One option that I've taken is to test the implementation of ControlA directly.  With this
approach one can either use A.) a protected setter and set the ControlB mock in the testclass
(provided they share the same directory structure) or B.) simply set the control using reflection
either explicitly or with a private setter.  Although I've most recently used option B.) our
team has come to the conclusion that option A.) is sufficient.  

Hope this helps,

-----Original Message-----
 From: Christopher Snow [] 
 Sent: Thursday, August 30, 2007 6:46 AM
 Subject: testing controls
  I have a control (ControlA) that has a reference to another control (ControlB). 
  I would like to test ControlA using a mock of ControlB.  I have created a
  setting to set ControlA's reference to ControlB from the test case.  However to
  do this, I need to put the setter in the business interface.  Is there a better
  Thanks in advance ...
  public class ControlAImpl ... {
     private ControlB controlB;
     public void setControlB( ControlB control ) {
        controlB = control
     // business logic
  public interface ControlA ...{
      // bad idea? non business method in business interface
      public void setControlB( ControlB control );
  public class ControlAImplTest extends ControlTestCase {
     private ControlA controlA;
     public void testX() {
        ControlB mockControlB = // create mock of ControlB
        controlA.setControlB( mockControlB )
        // test business logic here
  This message was sent using IMP, the Internet Messaging Program.
  This message has been scanned for viruses and
  dangerous content by MailScanner, and is
  believed to be clean.
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message