An image forming apparatus, comprising: an image former which includes an image carrier that carries a toner image to be transferred onto a sheet, a charger that charges a surface of the image carrier, an exposer that performs exposure of the surface of the image carrier and a developer that develops the toner image on the image carrier; a density detector which detects a density of an image formed by the image former; a controller which controls the image former to continuously perform image formation on a predetermined number of sheets and thereafter form a plurality of types of halftone test images on a sheet; a determiner which determines whether an image defect is generated and determines a factor causing the image defect by analyzing densities of the plurality of types of test images detected by the density detector; and an executer which executes a recovery mode which is set for each factor causing the image defect when the determiner determines that the image defect is generated, wherein the controller controls the image former to form a charged test image which is formed by the charger charging the surface of the image carrier and an uncharged test image which is formed without charging of the surface of the image carrier by the charger; and wherein the controller controls the image former to form, as the charged test image, an exposed test image which is formed by the exposer performing exposure and an unexposed test image which is formed without exposure by the exposer, wherein the determiner compares a density of the exposed halftone test image with a density of a last halftone test image formed before creation of the halftone test image, and when a density of a solid history portion in the exposed test image corresponding to a solid portion of the last image is different from a density of a white history portion in the exposed test image corresponding to a white portion of the last image, the determiner determines whether the image defect is generated. an image former which includes an image carrier that carries a toner image to be transferred onto a sheet, a charger that charges a surface of the image carrier, an exposer that performs exposure of the surface of the image carrier and a developer that develops the toner image on the image carrier; a density detector which detects a density of an image formed by the image former; a controller which controls the image former to continuously perform image formation on a predetermined number of sheets and thereafter form a plurality of types of halftone test images on a sheet; a determiner which determines whether an image defect is generated and determines a factor causing the image defect by analyzing densities of the plurality of types of test images detected by the density detector; and an executer which executes a recovery mode which is set for each factor causing the image defect when the determiner determines that the image defect is generated, wherein the controller controls the image former to form a charged test image which is formed by the charger charging the surface of the image carrier and an uncharged test image which is formed without charging of the surface of the image carrier by the charger; and wherein the controller controls the image former to form, as the charged test image, an exposed test image which is formed by the exposer performing exposure and an unexposed test image which is formed without exposure by the exposer, wherein the determiner compares a density of the exposed halftone test image with a density of a last halftone test image formed before creation of the halftone test image, and when a density of a solid history portion in the exposed test image corresponding to a solid portion of the last image is different from a density of a white history portion in the exposed test image corresponding to a white portion of the last image, the determiner determines whether the image defect is generated.