The invention discloses a method and device for automatically generating a
Java method unit
test case based on AI, and the method comprises the steps: building a structured
annotation specification, carrying out the automatic traversal and intelligent analysis of a
Java project, extracting a method signature, a
parameter type and a parameter constraint condition, constructing a
test data generation model, and carrying out the automatic generation of the
test case. The model is transmitted to an AI service to analyze
business logic and boundary conditions,
test case codes are generated, test cases are optimized and integrated to a project test
directory, finally, code areas with insufficient coverage are identified through coverage
rate analysis, a test completion strategy is generated, and iterative perfection of the test cases is completed. The technical problems that in the prior art, project-level automatic test case generation cannot be achieved, the generated test case cannot fully cover
business logic and boundary conditions, and context relation understanding is lacked are solved, full-automatic project-level test generation is achieved, and the
test efficiency and quality are improved.