1. A hardness tester measuring hardness of a sample by loading a predetermined test force on a surface of the sample with an indenter to form an indentation, and measuring dimensions of the indentation, the hardness tester comprising: a memory configured to associate and store a parts program having defined measurement conditions with respect to the sample, including a test position, with an image file obtained by capturing, using an image capturer, an image of a shape of the sample, for which the parts program has been created; a camera configured to acquire image data of the sample to be measured; and a processor comprising: a pattern matcher configured to perform a pattern matching process on the image data of the sample acquired by the camera, the pattern matcher further configured to perform the pattern matching process using the image file associated with the parts program stored in the memory; a determiner configured to determine, as a result of the pattern matching process of the pattern matcher, whether an image file exists which has a shape related to the image data of the sample acquired by the camera; a retriever configured to retrieve, in a case where the determiner determines that there is an image file having a related shape, the parts program associated with the image file from the memory; and a measurer configured to perform hardness testing on the sample to be measured and measures the hardness of the sample, based on the parts program retrieved by the retriever.