The paper describes the design of a Building Controls Virtual Test Bed (BCVTB), a simulation environment for the development of control algorithms and strategies for the major energy systems in buildings, HVAC, lighting, active facades and on-site generation. The BCVTB is based on the whole building energy simulation program EnergyPlus and includes both the pure simulation and the hardware-in-the-loop methods of implementing the controls. For convenience and scalability, the design of the hardware-in-the-loop interface for supervisory controls uses BACnet rather than the analog interface used for local loop control. The paper concludes with a case study of the use of a prototype implementation of the BCVTB to precommission the building control system for the naturally-ventilated San Francisco Federal Building. A number of problems were found with the control program, demonstrating the value of the precommissioning and the effectiveness of the technique.