In order to meet the latest requirements for sensor quality test in the industry, the sample sensor needs to be placed in the medium for the cold and hot shock test. However, the existing environmental test chamber cannot effectively control the temperature of the sample in the medium. This paper designs a control method based on the support vector machine (SVM) classification algorithm and K-means clustering combined with neural network correction. When testing sensors in a medium, the clustering SVM classification algorithm is used to distribute the control voltage corresponding to temperature conditions. At the same time, the neural network is used to constantly correct the temperature to reduce overshoot during the temperature-holding phase. Eventually, overheating or overcooling of the basket space indirectly controls the rapid rise or decrease in the temperature of the sensor in the medium. The test results show that this method can effectively control the temperature of the sensor in the medium to reach the target temperature within 15 min and stabilize when the target temperature is between 145 °C and −40 °C. The steady-state error is less than 0.31 °C in the high-temperature area and less than 0.39 °C in the low-temperature area, which well solves the dilemma of the current cold and hot shock test.