The invention relates to the field of linearity testing, and discloses a testing method for automatically testing linearity, which comprises the following steps: Step 1, setting a basic linearity testing interval, and carrying out local division; step 2, setting a step diameter range of an optical power test; 3, the light attenuation value is adjusted, so that the light power reaches the target light power generated by the test; step 4, adjusting the light attenuation value to enable the light power to reach the target light power to be tested, and repeating for five times; and Step 5, if the difference between the five times of light attenuation and the power value is smaller than the target value, the average value of the five times is used as the actual light attenuation and power value, and a responsivity linear test calibration calculation basis is generated. By adding a scheme capable of automatically testing the product linearity, the method is high in testing efficiency, can well adapt to mass production, is low in production cost, can provide convenient calibration measures, is convenient for a user to complete automatic testing by programming light attenuation and light power, can verify the testing accuracy, and guarantees the qualified rate of finished products.