This invention provides a
database testing method, apparatus, electronic device, and storage medium based
on protocol layer interaction. It generates test
SQL statements, performs parameterization to form parameter placeholder structures, and extracts parameter constraint information. Based on the parameter placeholder structures, parameter constraint information, and the current
session state, it generates protocol test cases, sequentially sends multiple protocol data packets, receives and parses response data packets returned by the
database system, records communication error information during response reading, and updates the current
session state based on the
parsing results of the response data packets. When the communication error information is detected during response reading, if a
crash occurs or the
verification results are inconsistent, an error report is generated. This invention can cover
protocol processing paths under different execution stages and interaction sequences, reduce invalid requests with semantically invalid or easily rejected requests, improve the validity of
test input, and enhance the coverage depth and defect detection capability of
database protocol testing.