In this paper, we present TrainSense, a novel infrastructure to support the development and testing of mobile sensing applications. TrainSense merges a mote and a model train into a single mobile unit, and enhances the basic model train infrastructure with several important features required for the evaluation of mobile scenarios. First, we develop a real-time controller to send control packets to model trains and motes to manage the network topology. Second, we design and implement a positioning system with centimeter precision. Third, we use the power available on the tracks to provide unlimited energy to the motes. Fourth, we provide a way for the motes to dock into a custom USB port, for reprogramming and data download. We evaluate TrainSense in two ways: (i) we establish the correctness of the implementation and measure the performance of its components, and (ii) we demonstrate its practical use with two sample wireless sensor network application scenarios: self-deployment and data muling.