The invention relates to a distributed automatic test system based on an OPC UA architecture Pub-Sub mode. The system architecture comprises a message center, a line model, a train model, a bridge model and a station yard graph model, wherein the line model, the train model, the bridge model and the station yard graph model form a dynamic star topology structure through the message center, the message center is set to be a message framework configured based on an OPC UA architecture Pub-Sub mode, supports a dynamic topology mode from n to m, and carries out IP address and port binding at a PUB end and a SUB end, and the line model, the train model, the bridge model and the station yard graph model communicate with one another by configuring the IP address of the message center. According to the test system, distributed communication and a star topology structure are realized by adopting a message queue based on an OPC UA publishing / subscribing mechanism, and compared with traditional mesh communication, the test system is simple in configuration and higher in efficiency, and a test environment is more convenient to expand.