Well integrity is crucially dependent on the bonding quality between cement and rock. Several studies have been made of this in the past, but none have taken into account that the drilled rock can be fractured and damaged during drilling. Especially a caprock fractured in the near-well zone can jeopardize well integrity. In this paper we have investigated the effect of shale caprock damage on the quality of well cement bonding to shale. Both intact and fractured rock has been cemented under realistic conditions, and the degree of the bonding (e.g. contact surface between the shale and cement) has been studied by X-ray computed tomography (CT) scanning. It was found that in the shale samples with fractured borehole, partial cement slurry penetration into the fracture network resulted in larger volume of leakage pathways than in the intact shale samples. The leakage potential through each of the samples was estimated based on connected cracks found by numerical calculations from three-dimensional (3D) reconstruction of CT data.