We demonstrate the use of the classical Ronchi test to characterize aberrations in focusing optics at a hard x-ray free-electron laser. A grating is placed close to the focus and the interference between the different orders after the grating is observed in the far field. Any aberrations in the beam or the optics will distort the interference fringes. The method is simple to implement and can provide single-shot information about the focusing quality. We used the Ronchi test to measure the aberrations in a nanofocusing Fresnel zone plate at the Linac Coherent Light Source at 8.194 keV.