Abstract. In the key areas of safety, the safety requirements of the software are becoming higher and higher. However, there are all kinds of safety testing methods, or the presence of state space explosion, or the test case is huge, and the safety testing efficiency is low. In order to solve this problem, this paper proposes a safety testing method, which is based on FAPM model. Getting danger of hazardous events which is through using dynamic fault tree analysis. And it is based on the call graph of the program to build the mapping relationship between basic events and operation, operation and code. Then, build a scene using a Markov model. According to the model generation of safety test case, and according to the test stop criterion to judge the adequacy of the testing.