Focused on the current problems of the automated testing for electromagnetic compatibility, this paper proposes a hierarchical and modular electromagnetic compatibility software architecture based on the OOP. This paper gives the design ideas, methods and main features and develops a test automation software for electromagnetic radiation safety margin based on this architecture. Experimental results show this software improves test efficiency, accuracy and achieves the desired effect compared with the manual testing. This software also reduces the intensity of the work of the testers and has a good value in engineering.