CN106776334B - Comment-based test case generation method and device - Google Patents

Comment-based test case generation method and device Download PDF

Info

Publication number
CN106776334B
CN106776334B CN201611235663.7A CN201611235663A CN106776334B CN 106776334 B CN106776334 B CN 106776334B CN 201611235663 A CN201611235663 A CN 201611235663A CN 106776334 B CN106776334 B CN 106776334B
Authority
CN
China
Prior art keywords
visual test
test case
code
test cases
visual
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611235663.7A
Other languages
Chinese (zh)
Other versions
CN106776334A (en
Inventor
李珂
黄威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201611235663.7A priority Critical patent/CN106776334B/en
Publication of CN106776334A publication Critical patent/CN106776334A/en
Application granted granted Critical
Publication of CN106776334B publication Critical patent/CN106776334B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for generating a test case based on annotation, wherein the method comprises the following steps: acquiring one or more sections of annotation content which is compiled according to a preset style and is related to a code; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. By utilizing the scheme, on one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in the process of generating the test case for the code is also avoided. Meanwhile, the test case is visualized, so that a user can check the test case conveniently, the threshold of the test case for the technical requirements of the user is reduced, and the method is simple and easy to operate.

Description

Comment-based test case generation method and device
Technical Field
The invention relates to the field of computer software, in particular to a method and a device for generating a test case based on annotation.
Background
After the code is written, corresponding test is required to be carried out so as to detect the function realized by the code and ensure the correctness of the code. And when testing, writing a corresponding test case for the code. Generally, when writing a test case, a QA (Quality Assurance) engineer and a code development engineer are required to communicate with each other or view a related development document, and a corresponding test case is written according to a communication result or document content.
The QA engineer needs to clean up the interface, return value, and function of each code, and then, on this basis, arrange the test cases suitable for the code. However, a great deal of manpower and time are required for writing the test cases, and the efficiency is low. Meanwhile, because the test cases need to be written manually, human errors easily occur, so that the test cases are not comprehensive, and the conditions of code test omission and the like are caused.
Disclosure of Invention
In view of the above, the present invention is proposed to provide a method and apparatus for generating test cases based on annotations that overcomes or at least partially solves the above problems.
According to one aspect of the invention, a method for generating a test case based on an annotation is provided, which comprises the following steps:
acquiring one or more sections of annotation content which is compiled according to a preset style and is related to a code;
extracting relevant information of the test case from one or more sections of annotation contents;
and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information.
According to another aspect of the present invention, there is provided an apparatus for generating test cases based on annotations, including:
the acquisition module is suitable for acquiring one or more sections of annotation content which is compiled according to a preset style and is related to the code;
the extraction module is suitable for extracting the relevant information of the test case from one or more sections of annotation contents;
and the generating module is suitable for generating one or more first visual test cases which correspond to one or more sections of annotation contents and are suitable for the code according to the extracted information.
According to the method and the device for generating the test case based on the annotation, provided by the invention, one or more sections of annotation contents which are compiled according to a preset pattern and are related to the code are obtained; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. And extracting the relevant information of the test case according to the annotation content of the code written in the preset style. And generating a visual test case correspondingly according to the relevant information of the test case. On one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in test case generation caused by human errors is avoided, and more comprehensive test cases can be generated for codes. Meanwhile, the test case is visualized, so that a user can check the test case conveniently, the threshold of the test case for the technical requirements of the user is reduced, and the method is simple and easy to operate.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a flow diagram of a method for generating test cases based on annotations according to an embodiment of the invention;
FIG. 2 shows a schematic diagram of a test case;
FIG. 3 illustrates a flow diagram of a method for generating test cases based on annotations according to another embodiment of the invention;
FIG. 4 illustrates a functional block diagram of an apparatus for generating test cases based on annotations according to an embodiment of the present invention;
FIG. 5 is a functional block diagram of an apparatus for generating test cases based on annotations according to another embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
FIG. 1 shows a flow diagram of a method for generating test cases based on annotations according to an embodiment of the invention. As shown in fig. 1, the method for generating a test case based on annotations specifically includes the following steps:
step S101, one or more sections of annotation content which is written according to a preset style and is related to the code is obtained.
Comments may be included in the code to help a user better understand the code. Generally, the annotation content may include, for example, the function name of the code, the implementation function, the interface parameter, and the like. Here, the style of the comment content is set. The annotation content of the preset style may include, for example, a code calling method, a URL address, a display name, a code version number, user right access information, a group name where the user right access information is located, various parameters of an interface, a return value judgment condition for normal execution, and the like.
Acquiring one or more sections of annotation content related to a code written according to a preset style, wherein if the code section needs a plurality of test cases, the corresponding related annotation content is a plurality of sections, and acquiring a plurality of sections of annotation content related to the code; if the code section only needs one test case, the corresponding related annotation content is a section, and a section of annotation content related to the code is obtained. For different codes, according to the requirements of the code test case, the related annotation content may be one or more segments, and the related one or more segments of annotation content of different codes are obtained.
Step S102, relevant information of the test case is extracted from one or more sections of annotation contents.
And extracting the information related to the test case from the acquired one or more sections of annotation contents. Such as extracting information of the execution environment, the product version, the interface parameters, the return value check information and the like of the test case. The execution environment defines environment information required by the code during execution; the product version is the version number of the code, and the original version number of the code can be updated after the code is modified; the product version records the updating of the code, so that the latest code can be conveniently tested; the interface parameters are important information in the test case, and the interface parameters can include parameter types, default values and the like; the parameter type is the data type of parameters such as String, int, etc., and the default value is the value of the interface parameter set for testing; different codes correspond to different interface parameters; the return value check information includes, for example, a return value in the case of normal execution, a return value or an abnormal code in the case of various abnormal executions, and is used to check whether the code execution is normal.
Step S103, generating one or more first visual test cases which correspond to one or more sections of annotation contents and are applicable to the code according to the extracted information.
And generating a first visual test case corresponding to the annotation content according to the extracted relevant information of the test case. And generating a first visual test case by one segment of annotation content, and generating a plurality of first visual test cases by a plurality of segments of annotation content. The generated first visual test case is applicable to testing of relevant code of the piece of annotated content.
The generated first visual test case can be in a page form as shown in fig. 2, and the content related to the test case is displayed on the page, so that the user can clearly know the content of the test case and can modify the content correspondingly. Such as setting interface parameters, inputting values for testing, etc. The generated first visual test case can also adopt other visual modes, so that the use by a user is facilitated. The invention is not limited in this regard.
According to the method for generating the test case based on the annotation, provided by the invention, one or more sections of annotation contents which are compiled according to a preset style and are related to the code are obtained; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. And extracting the relevant information of the test case according to the annotation content of the code written in the preset style. And generating a visual test case correspondingly according to the relevant information of the test case. On one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in test case generation caused by human errors is avoided, and more comprehensive test cases can be generated for codes. Meanwhile, the test case is visualized, so that a user can check the test case conveniently, the threshold of the test case for the technical requirements of the user is reduced, and the method is simple and easy to operate.
FIG. 3 shows a flow diagram of a method for generating test cases based on annotations according to another embodiment of the invention. As shown in fig. 3, the method for generating test cases based on annotations includes the following steps:
step S301, one or more sections of annotation content which is written according to a preset style and is related to the code is obtained.
Step S302, relevant information of the test case is extracted from one or more sections of annotation contents.
Step S303, generating one or more first visual test cases which correspond to one or more sections of annotation contents and are applicable to the code according to the extracted information.
The above steps can refer to steps S101 to S103 in the embodiment of fig. 1, and are not described herein again.
And step S304, newly building a second visual test case with empty test content.
Step S305, selecting at least two first visual test cases from the generated plurality of first visual test cases, and loading the at least two first visual test cases in the second visual test case to obtain a third visual test case.
Sometimes, codes have a correlation relationship of calling, and during testing, the contents of multiple sections of codes need to be combined together for testing. For the test situation, a second visual test case with empty test content is created, wherein all the test content is empty. Selecting at least two first visual test cases from the generated first visual test cases, and selecting two first visual test cases suitable for the two sections of codes from the generated first visual test cases if the two sections of codes need to be tested together; and if the multi-section codes are required to be tested together, selecting a plurality of first visual test cases suitable for the multi-section codes from the generated first visual test cases. And loading the at least two selected first visual test cases into a second visual test case so as to obtain a corresponding third visual test case. And obtaining a third visual test case comprising at least two first visual test cases.
At least two first visual test cases in the third visual test cases have a sequence, and the sequence can be set during loading and can also be adjusted after loading. The specific sequence is consistent with the execution sequence of the multiple sections of codes. And the return value of the previous first visual test case is the parameter of the next first visual test case. If the third visual test case comprises two first visual test cases, the return value of the first visual test case is a parameter for calling the second visual test case; if the third visual test case comprises three first visual test cases, the return value of the first visual test case is a parameter for calling the second visual test case; the return value of the second first visual test case is a parameter for calling the third first visual test case; if more first visual test cases are included in the third visual test case, the analogy can be repeated.
And S306, modifying the return value verification information of the at least two first visual test cases.
After the third visual test case is obtained, the third visual test case is suitable for a plurality of sections of codes to carry out combined test, and the first visual test case which is contained in the third visual test case is suitable for the condition that different return value verification information possibly exists when a single section of code is subjected to single test. At this time, the return value verification information of at least two first visual test cases included in the third visual test case may be modified. And modifying the return value verification information of at least two first visual test cases included in the third visual test case without influencing the return value verification information in the original first visual test case, wherein the modified return value verification information is only suitable for the third visual test case.
This step may be an optional step of this embodiment. If the returned value verification information is consistent when the multi-section codes are combined for testing and the single section of codes are subjected to the single test, the returned value verification information of at least two first visual test cases included in the third visual test case can be not modified, and the step is skipped.
Step S307, linking one or more first visual test cases and/or third visual test cases with the code.
And step S308, automatically executing the generated visual test case.
Step S309, after the code is modified, one or more first visual test cases and/or third visual test cases are/is automatically executed for performing regression test on the code.
The generated one or more first visual test cases and/or the third visual test cases are/is linked with the corresponding codes, for example, an interface is provided, a section of codes is linked with the one or more first visual test cases, and the generated one first visual test case can be automatically executed or the generated plurality of first visual test cases are automatically and sequentially executed to be associated. And the codes of the test inlet can be linked with the third visual test case during multi-section codes, and the third visual test case is automatically executed.
Further, after the code is modified, regression testing needs to be performed on the code. Therefore, after the code is modified, the linked visual test cases such as the one or more first visual test cases, the third visual test case and the like can be automatically executed to perform regression testing.
According to the method for generating the test case based on the annotation, provided by the invention, one or more sections of annotation contents which are compiled according to a preset style and are related to the code are obtained; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. And extracting the relevant information of the test case according to the annotation content of the code written in the preset style. And generating a visual test case correspondingly according to the relevant information of the test case. On one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in test case generation caused by human errors is avoided, and more comprehensive test cases can be generated for codes. Meanwhile, the test case is visualized, so that a user can check the test case conveniently, the threshold of the test case for the technical requirements of the user is reduced, and the method is simple and easy to operate. Further, for multiple sections of codes to be tested together, at least two first visual test cases are loaded in a second visual test case with empty test content to obtain a third visual test case, so that the problem of performing context-dependent combination test on the multiple sections of codes is solved. Meanwhile, if the return value verification information is different between the combined test and the single test, the return value verification information of the first visual test case included in the third visual test case can be modified. And during modification, the return value verification information in the original first visual test case is not influenced, so that the combination test and the monomer test are not influenced mutually. In order to make the test more convenient, the visual test case can be linked with the code, the generated visual test case is automatically executed, and manual intervention is not needed. Meanwhile, after the code is modified, the visual test case can be automatically executed again so as to carry out regression test on the code and discover errors generated by the fact that the code is modified to influence other unmodified codes as soon as possible.
FIG. 4 is a functional block diagram of an apparatus for generating test cases based on annotations according to an embodiment of the present invention. As shown in fig. 4, the apparatus for generating test cases based on annotations includes the following modules:
the obtaining module 410 is adapted to obtain one or more pieces of annotation content written in a preset style and related to the code.
Comments may be included in the code to help a user better understand the code. Generally, the annotation content may include, for example, the function name of the code, the implementation function, the interface parameter, and the like. Here, the style of the annotation content is set by the acquisition module 410. The annotation content of the preset style may include, for example, a code calling method, a URL address, a display name, a code version number, user right access information, a group name where the user right access information is located, various parameters of an interface, a return value judgment condition for normal execution, and the like.
The obtaining module 410 obtains one or more sections of annotation content related to the code written according to a preset style, wherein if the section of code requires a plurality of test cases, the corresponding related annotation content is a plurality of sections, and the obtaining module 410 obtains the plurality of sections of annotation content related to the code; if the section of code only needs one test case, the corresponding related annotation content is a section, and the obtaining module 410 obtains a section of annotation content related to the code. For different codes, the related annotation content may be one or more segments according to the requirements of the code test case, and the obtaining module 410 obtains the related one or more segments of annotation content of different codes.
And the extracting module 420 is adapted to extract relevant information of the test case from the one or more pieces of annotation content.
The extracting module 420 extracts information related to the test case from the one or more pieces of annotation content acquired by the acquiring module 410. For example, the extraction module 420 extracts information such as the execution environment, the product version, the interface parameter, and the return value verification information of the test case. The execution environment defines environment information required by the code during execution; the product version is the version number of the code, and the original version number of the code can be updated after the code is modified; the product version records the updating of the code, so that the latest code can be conveniently tested; the interface parameters are important information in the test case, and the interface parameters can include parameter types, default values and the like; the parameter type is the data type of parameters such as String, int, etc., and the default value is the value of the interface parameter set for testing; different codes correspond to different interface parameters; the return value check information includes, for example, a return value in the case of normal execution, a return value or an abnormal code in the case of various abnormal executions, and is used to check whether the code execution is normal.
The generating module 430 is adapted to generate one or more first visual test cases applicable to the code corresponding to the one or more pieces of annotation content according to the extracted information.
The generating module 430 generates a first visual test case corresponding to the annotation content according to the extracted relevant information of the test case. The one-segment annotation content generation module 430 generates a first visual test case, and the multi-segment annotation content generation module 430 generates a plurality of first visual test cases. The first visual test case generated by the generation module 430 is applicable to testing of relevant code for the piece of annotated content.
The first visual test case generated by the generating module 430 may display all contents related to the test case on a page in a manner as shown in fig. 2, so that a user can clearly know the contents of the test case and can perform corresponding modification. Such as setting interface parameters, inputting values for testing, etc. The first visual test case generated by the generating module 430 may also adopt other visual modes, which is convenient for the user to use. And are not limited herein.
According to the test case generation device based on the annotations, provided by the invention, one or more segments of annotation contents which are compiled according to a preset style and are related to the code are obtained; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. And extracting the relevant information of the test case according to the annotation content of the code written in the preset style. And generating a visual test case correspondingly according to the relevant information of the test case. On one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in test case generation caused by human errors is avoided, and more comprehensive test cases can be generated for codes. Meanwhile, the visual test case is more convenient for the user to check the test case, the threshold of the test case for the technical requirements of the user is also reduced, and the visual test case is simpler and easier to operate.
FIG. 5 is a functional block diagram of an apparatus for generating test cases based on annotations according to another embodiment of the present invention. As shown in fig. 5, compared to fig. 4, the apparatus for generating test cases based on annotations further includes the following modules:
and the new creating module 440 is adapted to create a second visual test case with empty test content.
The loading module 450 is adapted to select at least two first visual test cases from the generated plurality of first visual test cases, and load the at least two first visual test cases in the second visual test case to obtain a third visual test case.
Sometimes, codes have a correlation relationship of calling, and during testing, the contents of multiple sections of codes need to be combined together for testing. For such a test situation, the creating module 440 first creates a second visual test case with empty test contents, where all the test contents are empty. The loading module 450 selects at least two first visual test cases from the generated plurality of first visual test cases, and if two sections of codes need to be tested together, the loading module 450 selects two first visual test cases suitable for the two sections of codes from the generated plurality of first visual test cases; if multiple pieces of code are required to be tested together, the loading module 450 selects multiple first visual test cases suitable for the multiple pieces of code from the multiple first visual test cases that have been generated. The loading module 450 loads the at least two selected first visual test cases into the second visual test case, so as to obtain a corresponding third visual test case. That is, the loading module 450 obtains a third visual test case including at least two first visual test cases.
At least two first visual test cases in the third visual test cases obtained by the loading module 450 have a sequence, and the sequence may be set when the loading module 450 is loaded or may be adjusted after the loading module 450 is loaded. The specific sequence is consistent with the execution sequence of the multiple sections of codes. And the return value of the previous first visual test case is the parameter of the next first visual test case. For example, the third visual test case includes two first visual test cases, and the return value of the first visual test case is a parameter for calling the second visual test case; if the third visual test case comprises three first visual test cases, the return value of the first visual test case is a parameter for calling the second visual test case; the return value of the second first visual test case is a parameter for calling the third first visual test case; if the third visual test case comprises more first visual test cases, the analogy can be performed in sequence.
And a modification module 460 adapted to modify the return value verification information of the at least two first visual test cases.
After the loading module 450 is executed to obtain the third visual test case, because the third visual test case is suitable for performing a combination test on multiple sections of codes, the third visual test case and the first visual test case included therein are suitable for situations where different return value verification information may exist when a single section of code is subjected to a single test. At this time, the modification module 460 may modify the return value verification information of at least two first visual test cases included in the third visual test case. The modification module 460 modifies the return value verification information of at least two first visual test cases included in the third visual test case without affecting the return value verification information in the original first visual test case, and the modified return value verification information is only applicable to the third visual test case.
The invention modification module 460 is an optional module. If the returned value verification information is consistent when the combined test of multiple sections of codes and the single test of a single section of codes are performed together, the modification module 460 may not be executed.
And a linkage module 470, adapted to link the one or more first visual test cases and/or the third visual test cases with the code.
And the execution module 480 is adapted to automatically execute the generated visual test case.
The regression module 490 is adapted to automatically execute the one or more first visual test cases and/or the third visual test cases after the code is modified for performing regression testing on the code.
The linkage module 470 is configured to link the generated one or more first visual test cases and/or the third visual test cases with the corresponding codes, for example, the linkage module 470 provides an interface to link a section of code with the one or more first visual test cases, and the execution module 480 may automatically execute the generated one first visual test case, or the execution module 480 automatically and sequentially executes the generated plurality of first visual test cases to associate. The multi-section code linkage module 470 can link the code of the test entry with the third visual test case, and the execution module 480 automatically executes the third visual test case.
Further, after the code is modified, regression testing needs to be performed on the code. Thus, after the code is modified, the regression module 490 may automatically execute one or more visual test cases such as the first visual test case, the third visual test case, etc. linked thereto to perform the regression test.
According to the test case generation device based on the annotations, provided by the invention, one or more segments of annotation contents which are compiled according to a preset style and are related to the code are obtained; extracting relevant information of the test case from one or more sections of annotation contents; and generating one or more first visual test cases which correspond to one or more pieces of annotation content and are applicable to the code according to the extracted information. And extracting the relevant information of the test case according to the annotation content of the code written in the preset style. And generating a visual test case correspondingly according to the relevant information of the test case. On one hand, the time and labor spent by the QA to communicate with developers or view related documents are saved, and the efficiency of generating test cases is greatly improved. On the other hand, omission in test case generation caused by human errors is avoided, and more comprehensive test cases can be generated for codes. Meanwhile, the visual test case is more convenient for the user to check the test case, the threshold of the test case for the technical requirements of the user is also reduced, and the visual test case is simpler and easier to operate. Further, for multiple sections of codes to be tested together, at least two first visual test cases are loaded in a second visual test case with empty test content to obtain a third visual test case, so that the problem of performing context-dependent combination test on the multiple sections of codes is solved. Meanwhile, if the return value verification information is different between the combined test and the single test, the return value verification information of the first visual test case included in the third visual test case can be modified. And during modification, the return value verification information in the original first visual test case is not influenced, so that the combination test and the monomer test are not influenced mutually. In order to make the test more convenient, the visual test case can be linked with the code, the generated visual test case is automatically executed, and manual intervention is not needed. Meanwhile, after the code is modified, the visual test case can be automatically executed again so as to carry out regression test on the code and discover errors generated by the fact that the code is modified to influence other unmodified codes as soon as possible.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components in an annotation based generation test case apparatus according to embodiments of the invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (10)

1. A method for generating test cases based on annotations comprises the following steps:
acquiring one or more sections of annotation content which is compiled according to a preset style and is related to a code; wherein, the annotation content of the preset style comprises: code calling method, interface parameter, return value judgment condition of normal execution;
extracting relevant information of the test case from the one or more segments of the annotation content, wherein the relevant information comprises: the execution environment, the product version, the interface parameters and the return value verification information of the test case;
generating one or more first visual test cases which correspond to one or more sections of annotation contents and are applicable to the code according to the extracted information;
wherein the method further comprises:
newly building a second visual test case with empty test content;
selecting at least two first visual test cases from the generated plurality of first visual test cases, and loading the at least two first visual test cases into the second visual test case to obtain a third visual test case; the at least two first visual test cases have a sequence, and the return value of the previous first visual test case is the parameter of the next first visual test case.
2. The method of claim 1, wherein the interface parameter comprises a parameter type or a default value.
3. The method of claim 1, wherein after the loading of the at least two first visual test cases in the second visual test case, the method further comprises:
and modifying the return value verification information of the at least two first visual test cases.
4. The method according to any one of claims 1-3, wherein the method further comprises:
linking the one or more first visual test cases and/or the third visual test cases with the code;
and automatically executing all the generated visual test cases.
5. The method of claim 4, wherein the method further comprises:
after the code is modified, automatically executing the one or more first visual test cases and/or the third visual test cases for performing regression testing on the code.
6. An annotation based test case generation apparatus, comprising:
the acquisition module is suitable for acquiring one or more sections of annotation content which is compiled according to a preset style and is related to the code; wherein, the annotation content of the preset style comprises: code calling method, interface parameter, return value judgment condition of normal execution;
the extraction module is suitable for extracting relevant information of the test case from the one or more sections of annotation contents, and comprises: the execution environment, the product version, the interface parameters and the return value verification information of the test case;
the generating module is suitable for generating one or more first visual test cases which correspond to one or more sections of annotation contents and are suitable for the code according to the extracted information;
wherein the apparatus further comprises:
the new building module is suitable for building a second visual test case with empty test content;
the loading module is suitable for selecting at least two first visual test cases from the generated plurality of first visual test cases, and loading the at least two first visual test cases into the second visual test case to obtain a third visual test case; the at least two first visual test cases have a sequence, and the return value of the previous first visual test case is the parameter of the next first visual test case.
7. The apparatus of claim 6, wherein the interface parameter comprises a parameter type or a default value.
8. The apparatus of claim 6, wherein the apparatus further comprises:
and the modification module is suitable for modifying the return value verification information of the at least two first visual test cases.
9. The apparatus of any of claims 6-8, wherein the apparatus further comprises:
the linkage module is suitable for linking the one or more first visual test cases and/or the third visual test cases with the codes;
and the execution module is suitable for automatically executing all the generated visual test cases.
10. The apparatus of claim 9, wherein the apparatus further comprises:
and the regression module is suitable for automatically executing the one or more first visual test cases and/or the third visual test cases after the code is modified so as to perform regression testing on the code.
CN201611235663.7A 2016-12-28 2016-12-28 Comment-based test case generation method and device Active CN106776334B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611235663.7A CN106776334B (en) 2016-12-28 2016-12-28 Comment-based test case generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611235663.7A CN106776334B (en) 2016-12-28 2016-12-28 Comment-based test case generation method and device

Publications (2)

Publication Number Publication Date
CN106776334A CN106776334A (en) 2017-05-31
CN106776334B true CN106776334B (en) 2021-03-23

Family

ID=58924653

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611235663.7A Active CN106776334B (en) 2016-12-28 2016-12-28 Comment-based test case generation method and device

Country Status (1)

Country Link
CN (1) CN106776334B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108763091B (en) * 2018-05-31 2022-05-27 恒生电子股份有限公司 Method, device and system for regression testing
CN110750434A (en) * 2018-07-23 2020-02-04 北京奇虎科技有限公司 Interface testing method and device, electronic equipment and computer readable storage medium
CN108845953B (en) * 2018-08-27 2023-02-17 北京奇虎科技有限公司 Interface testing method and device
CN109213683A (en) * 2018-09-06 2019-01-15 无线生活(杭州)信息科技有限公司 Method for generating test case and device
CN109614324B (en) * 2018-12-03 2022-02-08 北京云测信息技术有限公司 Test case generation method and device
CN111274120B (en) * 2018-12-05 2024-02-02 三六零科技集团有限公司 Interface document verification method and device
CN110457028B (en) * 2019-08-06 2023-09-01 软通智慧信息技术有限公司 Page visual programming method, device, server and storage medium
CN113419954B (en) * 2021-06-25 2023-03-31 陕西浪潮英信科技有限公司 Execution method and system of automation use case of cloud operating system and related components

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN103473045A (en) * 2013-08-27 2013-12-25 广州华多网络科技有限公司 Method and device for generating interface documents
CN104407973A (en) * 2014-11-25 2015-03-11 珠海格力电器股份有限公司 Automatic unit test realizing method and device
CN105138461A (en) * 2015-09-23 2015-12-09 网易(杭州)网络有限公司 Interface testing method and device for application program

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7266808B2 (en) * 2001-08-10 2007-09-04 Parasoft Corporation Method and system for dynamically invoking and/or checking conditions of a computer test program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN103473045A (en) * 2013-08-27 2013-12-25 广州华多网络科技有限公司 Method and device for generating interface documents
CN104407973A (en) * 2014-11-25 2015-03-11 珠海格力电器股份有限公司 Automatic unit test realizing method and device
CN105138461A (en) * 2015-09-23 2015-12-09 网易(杭州)网络有限公司 Interface testing method and device for application program

Also Published As

Publication number Publication date
CN106776334A (en) 2017-05-31

Similar Documents

Publication Publication Date Title
CN106776334B (en) Comment-based test case generation method and device
US20210334093A1 (en) Automating Identification of Code Snippets for Library Suggestion Models
US20200293433A1 (en) Automating Identification of Test Cases for Library Suggestion Models
US11494181B2 (en) Automating generation of library suggestion engine models
US9389849B2 (en) Test case pattern matching
US20200319878A1 (en) Library Model Addition
US8943423B2 (en) User interface indicators for changed user interface elements
EP3695310A1 (en) Blackbox matching engine
CN105446874B (en) A kind of detection method and device of resource distribution file
CN109947637B (en) Automatic testing method, device, equipment and medium for webpage compatibility
JP2015043198A (en) Analysis system, analysis method and analysis program
CN106708704B (en) Method and device for classifying crash logs
JP6440895B2 (en) Software analysis apparatus and software analysis method
CN106933591A (en) The method and device that code merges
JP6310527B1 (en) Object analysis apparatus, object analysis method, and program
US20090217259A1 (en) Building Operating System Images Based on Applications
CN110737573B (en) Method and device for automatically testing user interface UI
US9396239B2 (en) Compiling method, storage medium and compiling apparatus
CN107885493B (en) Program creation support method and program creation support device
CN110399156B (en) On-orbit upgrading method for aerospace software
CN111367752B (en) Method, device and storage medium for identifying Android true machine and simulator
JP2014232428A (en) Test execution assisting device, test system, test execution method, and test execution assisting program
JP4149047B2 (en) Simulator
CN111414301B (en) Method and device for debugging application program
CN109960529B (en) Program code repairing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant