The present application provides a method for generating a traversal test command, characterized in that, any command i to be tested is represented by n i composed of command fragments, and n i ≥1, the method includes: in the case of not specifying the association basis, invoking the built-in association function of the system to obtain a first command fragment set, the first command fragment set includes: all possible first command fragments of the command to be tested The command fragment that appears in the position; for each command fragment in the first command fragment set, take the command fragment as the root node, call the built-in association function of the system, and generate the association fragment tree. In the association fragment tree, any non-root node The corresponding command fragments are based on the sequence formed by the corresponding command fragments of all ancestor nodes; traverse each associative fragment tree to obtain a directed path formed from any root node to any leaf node, and according to each Generate the command to be tested from the command fragment sequence corresponding to the path.