The invention proposes a method and a device for generating a test case. The method comprises the following steps: obtaining an input instrument and a configuration film, wherein the input instruction comprises a test type parameter; the configuration film comprises a module, class information, function information of the tested function and a test parameter; determining the test type according to the test type parameter, and structuring test data according to the test type and the test parameter; rendering the preset template according to the template, the class information, the function information of the tested function and the test data, so as to generate the test case. By adopting the method disclosed by the embodiment of the invention, on one hand, automatic generation of the function test case is achieved without artificially compiling the test case of the tested function, so as to improve the test accuracy, and on the other hand, the test type is determined according to the test type parameter, and support of a plurality of different test modes is achieved, so that the supported test modes are diversified.