X-ray wavefront measurement is an important beam diagnostic tool, especially for the diffraction-limited X-ray beam. These in situ diagnostics give a better understanding of beam imperfections, and they enable feedback for possible corrections and/or optical alignment improvements. Hartmann wavefront sensing is one of the promising techniques to perform in situ X-ray wavefront measurements. In this work, a simulation tool of the X-ray Hartmann Wavefront Sensor (HWS) is developed under the Synchrotron Radiation Workshop (SRW) framework. Using this new simulation capability, one can take advantage of the full SRW package to simulate Hartmann wavefront sensing with the beam traveling from the X-ray source to the sample through different X-ray optical components. This SRW HWS simulation tool can help to optimize the wavefront sensor parameters for a specific X-ray energy range. It can also simulate an in situ wavefront measurement experiment with a particular beamline optical layout and predict the expected results of the wavefront measurement under different beamline configurations.