CN115686479A - File creation method and related device - Google Patents

File creation method and related device Download PDF

Info

Publication number
CN115686479A
CN115686479A CN202211136794.5A CN202211136794A CN115686479A CN 115686479 A CN115686479 A CN 115686479A CN 202211136794 A CN202211136794 A CN 202211136794A CN 115686479 A CN115686479 A CN 115686479A
Authority
CN
China
Prior art keywords
code
file
directory
test case
creating
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.)
Pending
Application number
CN202211136794.5A
Other languages
Chinese (zh)
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202211136794.5A priority Critical patent/CN115686479A/en
Publication of CN115686479A publication Critical patent/CN115686479A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a file creating method, a file creating device, electronic equipment, a storage medium and a product, and relates to the technical field of software development, in particular to the technical field of automatic code generation. The specific implementation scheme is as follows: in response to the detection of a creation instruction and a first directory name, creating a first directory corresponding to the first directory name based on a pre-written script code, wherein the first directory comprises a code directory and a code file; based on the script codes, creating a test case file corresponding to the code file, wherein the test case file comprises test cases of testable codes in the code file; executing a code test based on the test case file; based on the results of the code test, the problem existing in the code file is corrected. The testable code can be automatically generated through the method and the device, and the research and development efficiency and the code quality are improved.

Description

File creation method and related device
Technical Field
The present disclosure relates to the field of software development technologies, and in particular, to the field of code automatic generation technologies, and in particular, to a file creation method, an apparatus, an electronic device, a storage medium, and a product.
Background
In the process of developing a workflow basic component library project, a developer needs to repeatedly create the same code directory for further development each time a requirement is developed, and a code file is consistent with the directory of other developers, the naming specification is also consistent, and the directory path is also consistent. Similar files need to be repeatedly created again under the same directory.
In the related art, a developer needs to do the same work repeatedly in the process of creating a file repeatedly.
Disclosure of Invention
The disclosure provides a file creating method, a file creating device, electronic equipment, a storage medium and a product.
According to a first aspect of the present disclosure, there is provided a file creation method, the method including:
in response to the detection of a creation instruction and a first directory name, creating a first directory corresponding to the first directory name based on a pre-written script code, wherein the first directory comprises a code directory and a code file; and creating a test case file corresponding to the code file based on the script code, wherein the test case file comprises test cases of the testable codes in the code file.
According to a second aspect of the present disclosure, there is provided an apparatus for creating a file, the apparatus including:
the code creating module is used for creating a first directory corresponding to a first directory name based on a pre-written script code in response to detecting a creating instruction and the first directory name, wherein the first directory comprises a code directory and a code file; and the test case creating module is used for creating a test case file corresponding to the code file based on the script code, and the test case file comprises a test case of the testable code in the code file.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the first aspect.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method according to the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer product comprising a computer program which, when executed by a processor, implements the method according to the first aspect.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic diagram of an application environment in accordance with an embodiment of the present disclosure;
fig. 2 is a schematic flowchart illustrating a file creating method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating a code creation method provided by an embodiment of the present disclosure;
FIG. 4 is a diagram illustrating a tree directory structure provided by an embodiment of the present disclosure;
fig. 5 shows a flowchart of a test case creation method provided by the embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a file creating apparatus provided by an embodiment of the present disclosure;
FIG. 7 illustrates a schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the process of software project research and development and code writing such as a component library, research and development personnel need to repeatedly create the same code directory for further development each time one requirement begins to be developed, and a code file is consistent with directories where other development personnel are located, naming specifications are consistent, and directory paths are consistent. Under the same directory, similar files need to be repeatedly created again.
In the related technology, after receiving a development task, a developer manually creates a file directory and an internal code file, and when creating the file directory, a corresponding necessary file needs to be created according to project requirements. For example: source code files, style files, unit test files, demo files, etc. Corresponding fixed code templates (such as function names, style introduction, framework tool introduction and the like) need to be written manually in corresponding files. The operation is complicated, the repeated operation is too much, and in the project of the component library, if the later-stage iteration components are too much, the development labor is wasted. The code specification is unified by manual writing, and errors are easy to occur.
Based on the above, the present disclosure provides a file creating method and apparatus, which automatically generate a file required by a developer by executing a script written in advance, and generate a code template in the file, thereby reducing the amount of repeated labor of the developer in project development, and improving the development efficiency. Further, based on the script code, a test case file corresponding to the code file is created, wherein the test case file comprises a test case of the testable code in the code file. And a testable code file is generated, and the code quality is improved.
The file creating method provided by the application can be applied to the application environment shown in FIG. 1. In which a terminal 101 communicates with a server 102 via a network. The terminal 101 may be configured to obtain operations and information input by a user, and the server 102 may execute a script to generate a first directory, a corresponding file, and a template code in the file. The terminal 101 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 102 may be implemented by an independent server or a server cluster formed by a plurality of servers.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the disclosure, as detailed in the appended claims.
Fig. 2 shows a flowchart of a file creating method provided by an embodiment of the present disclosure, and as shown in fig. 2, the method may include:
in step S210, in response to detecting the creation instruction and the first directory name, a first directory corresponding to the first directory name is created based on script code written in advance.
Wherein, the first directory comprises a code directory and a code file.
In the embodiment of the disclosure, the automatic creation of the file and the automatic generation of the code template can be realized based on the node service.
In the present disclosure, a creation instruction, for example, npm run new, may be customized in advance. Wherein the creation instruction is used for indicating the creation of the first directory.
For example, if it is detected that the user inputs a command line npm run new through the node service, the user is prompted to input a first directory name. In response to detecting the first directory name input by the user, automatically executing the script code, creating a first directory with a name corresponding to the first directory name, and further generating a code file and a code directory in the first directory.
In the present disclosure, the first directory name may be a name of the project file to be created, the first directory name being a root directory name of the project file to be created. Files of the respective functions supported by the item to be created and named names of the files of the respective functions may also be created under the first directory name in the present disclosure.
In the present disclosure, a code file may be understood as a development file of a development project, and a code directory may be understood as a storage path of a code file.
In the embodiment of the present disclosure, after the automatic creation of the first directory is completed, a code file template corresponding to a code file in the first directory may be further acquired. A code file template can be preset, and the code file template comprises a plurality of template codes. The template codes can be set in categories and can be filled according to the requirements of different modules in the code file. And filling codes into corresponding code files in the first directory based on the pre-written script codes and the code file template.
In the disclosed embodiment, the script code contains various parameters needed to automatically produce code files and directories. The script code may be executed, typically stored in the form of a file, which may be accessed and executed, for example, in a command line. The script code may receive input parameters such as the name of the root directory (i.e., the aforementioned first directory) of the code file and directory to be created.
In step S220, based on the script code, a test case file corresponding to the code file is created, where the test case file includes a test case of the testable code in the code file.
In an embodiment of the present disclosure, the test case file corresponds to part or all of the code files. The code files include various types of files such as executable files, library files, configuration files, and the like. Not all code files need to be tested, and therefore not all code files need corresponding test case files. According to the selection of the test strategy, part of key code files can be selected for testing, for example, a test case file is set for an executable file; or set test case files to configuration files, etc. The present disclosure is not so limited.
In the embodiment of the present disclosure, the code file includes different parts and different modules, such as function names, style introductions, framework tool introductions, and the like. Different parts of the code file do not all belong to the code that needs to be tested. Whether the test case code needs to be set can be selected according to the properties of the code part or the code module in the code file. For example, for code that introduces classes, testing is generally not required. For the function modules in the code, corresponding test case codes can be set.
According to the file creating method provided by the disclosure, the code file and the code directory in the corresponding first directory can be automatically generated according to the creating instruction input by the user and the name of the first directory, so that the writing process of repeated codes can be reduced, and the research and development efficiency and the standardization are improved. And creating a test case file corresponding to the code file, wherein the test case file comprises the test cases of the testable codes in the code file. The test environment of the code file is automatically and efficiently generated according to the code file, namely the code file can be tested, the test can be automatically executed, and the code quality is improved.
The following embodiment will explain the creation of the first directory corresponding to the first directory name.
Fig. 3 shows a flowchart of a code creation method provided by an embodiment of the present disclosure, and as shown in fig. 3, the method may include:
the script code includes: at least one of a code directory name, a code directory location, a code file name, and a code file location.
The creating of the first directory corresponding to the first directory name includes:
in step S310, a code directory name, a code directory location, a code file name, and a code file location in the script code are obtained.
In step S320, a tree directory structure of the first directory is generated based on the code directory name, the code directory location, the code file name, and the code file location.
In the embodiment of the present disclosure, a corresponding directory structure of each project may be predetermined according to each project to be developed. For example, directory a includes directory B and directory C, and directory B also includes directory D, and the directory structure is understood that directory B and directory C are subdirectories of directory a, and directory folder D is a subdirectory of directory B.
Further, in the present disclosure, a target project to be developed may be determined, and a directory structure of the target project may be obtained according to a creation instruction input by a user. And the user inputs a creating instruction which calls and executes the script code. Taking the script code executed in the command line as an example, assume that the creation instruction input by the user is npm run new, where npm indicates that the environment in which the code runs is node. After the script is executed, the user is prompted to input a first directory name, for example, a Block, and as a result of the script execution, an item root directory (i.e., the first directory) named Block is generated in the current directory where the script is located. The first directory may also be placed according to predefined locations. Illustratively, when developing the component Block, all components are located under the predefined "src/components/" directory. The first directory name that can be entered is Block. Thus, a first directory specifying that the first directory name is Block may be created under the "src/components/" directory.
In the embodiment of the disclosure, the code directory location may adopt a path representation or a nested relation representation. When the path representation is adopted, for example, the code directory location includes the following directories: "/Block/Button", "/Block/Text", "/Block/Input". When the nested relational representation is adopted, for example, the code directory location includes a plurality of directories as follows: the directories "Button", "Text" and "Input" are all located under the directory "Block".
In the embodiment of the present disclosure, the code file position may adopt a path representation or a nested relation representation. When the path representation method is adopted, for example, the code file position includes the following files: "/Block/Button/index1.Tsx", "/Block/Text/index2.Tsx", "/Block/Input/index3.Tsx". When the nested relation representation method is adopted, for example, the code directory location includes the following files: the file "index1.Tsx" is located under the directory "Button"; the file "index2.Tsx" is located under the directory "Text"; the file "index3.Tsx" is located under the directory "Input".
In the disclosed embodiment, the tree directory structure is as shown in fig. 4.
In step S330, the tree directory structure is traversed, and the code directory is generated at the code directory location according to the code directory name.
In embodiments of the present disclosure, the traversal may employ breadth-first traversal. As shown in fig. 4, the code directory is generated by sequentially traversing "Block", "Button", "Text", and "Input". The traversal may also employ depth-first traversal.
In step S340, traversing the tree directory structure, and generating the code file at the code file location according to the code file name.
In embodiments of the present disclosure, the traversal may employ breadth-first traversal. As shown in fig. 4, the code file is sequentially generated by sequentially traversing "Block", "Button", "Text", "Input", "index1.tsx", "index2.tsx", and "index3.tsx". The traversal may also employ depth-first traversal.
In the embodiment of the present disclosure, after the file is created successfully, the code template in each file may also be automatically generated.
By automatically generating the corresponding directory and the corresponding file in the directory through the method, the code directory can be quickly and automatically created, and the directory structure is standard and consistent. And because the unified template is used for creating the file directory, the difference caused by different personnel creating project files can be reduced, so that the project development is more standard and unified, and the maintainability in the later period is improved.
Fig. 5 shows a flowchart of a test case creation method provided by an embodiment of the present disclosure, and as shown in fig. 5, the method may include:
in step S510, a corresponding test case template is obtained based on the type of the testable code in the code file.
In step S520, based on the test case template, a test case code is filled into the test case file.
In the embodiment of the present disclosure, different test case templates may be preset.
In the embodiment of the present disclosure, the test case file corresponds to part or all of the code files. The code files include various types of files such as executable files, library files, configuration files, and the like. Not all code files need to be tested, and therefore not all code files need corresponding test case files. According to the selection of the test strategy, part of the key code files can be selected for testing, for example, a test case file is set for an executable file; or setting a test case file to the configuration file, etc. The present disclosure is not so limited.
In the embodiment of the present disclosure, the code file includes different parts and different modules, such as function names, style introductions, framework tool introductions, and the like. Different parts of the code file do not all belong to the code that needs to be tested. Whether the test case code needs to be set or not can be selected according to the attributes of the code part or the code module in the code file. For example, for code that introduces classes, testing is generally not required. For the function module in the code, corresponding test case code can be set
In the embodiment of the present disclosure, according to the created first directory "Block", all the code files "index1.Tsx", "index2.Tsx", "index3.Tsx" included in the first directory may be acquired. According to a predetermined test strategy, a code file to be tested, such as "index1.Tsx", may be obtained.
Illustratively, the following fields are the automatically generated Block source file contents.
Figure BDA0003852433710000081
Analyzing the code of the code file ' index1.Tsx ' to be tested, wherein the code comprises three parts of an ' import ' introduction module, a ' Block ' function module and an ' export module. In the current test strategy, an import module and an export module of a code file do not belong to codes to be tested. Therefore, only the function Block in the code file "index1.Tsx" belongs to the code to be tested. Thus, the corresponding test case code will be generated from the predefined test case template.
In the embodiment of the present disclosure, a corresponding test case file "index1.Test. Tsx" is generated for the code file "index1.Tsx". The test case file comprises: <xnotran> , , , , "__ test __". </xnotran>
And filling the test case codes into a test case file 'index 1.Test. Tsx' according to the test case template. Therefore, the next testing work can be carried out based on the generated test case file.
In the embodiment of the present disclosure, after the test case file corresponding to the code file is created: executing a code test based on the test case file 'index 1.Test. Tsx'; based on the results of the code test, the problems present in the code file are corrected.
Wherein, the correcting the problem existing in the code file comprises: acquiring a corresponding code correction template based on the type of the problem; and correcting the problems in the code file based on the code correction template. For example, the problem is that if the function name uses the reserved word "const", the corresponding code modification template may be enabled, at which point the template prompts the user to enter a new function name, and if no user input is received, a suffix is automatically added to the original function name, thereby circumventing the restrictions of the reserved word.
According to the method, the script code comprises a code file template and a test case template, after the script code is automatically executed, the script can automatically generate codes in the code file template to a corresponding code file, and the script can automatically generate codes in the test case template to a corresponding test case file. The writing process of repeated codes is greatly reduced, and the research and development efficiency and the specification are greatly improved.
In the embodiment of the disclosure, the code file template, the test case template and the code correction template are determined not to meet the requirements, and the templates can be modified.
In response to detecting a modification operation on the code file template, making a first modification to the code file based on the modification operation; and carrying out second modification on the test case file based on the first modification.
And in response to detecting a second modification operation on the test case template, performing third modification on the test case file based on the second modification operation.
In response to detecting a third modify operation on the code revision template, performing a code test based on the third modify operation; based on the results of the code test, the problems present in the code file are corrected.
In the present disclosure, modifying a template may be for a separate file, such that the template code in the file is modified, and the code template in the template file is preserved. Batch modifications may also be made to multiple template files.
The code file further includes at least one of data of the operator interface component, a style of the operator interface, and a code of the operator interface event.
For example, the interface components may include components for user input, components that expose test code directories, script code, code files, and/or test case file exposure components.
Based on the same principle as the method shown in fig. 2, fig. 6 shows a schematic structural diagram of a file creating apparatus provided by the embodiment of the present disclosure, and as shown in fig. 6, the file creating apparatus 600 may include:
a code creating module 601, configured to create, in response to detecting a creation instruction and a first directory name, a first directory corresponding to the first directory name based on a script code written in advance, where the first directory includes a code directory and a code file; a test case creating module 602, configured to create, based on the script code, a test case file corresponding to the code file, where the test case file includes a test case of a testable code in the code file.
In an embodiment of the present disclosure, the script code includes at least one of:
code directory name, code directory location, code file name, code file location.
In this disclosure, the code creating module 601 is configured to obtain a code directory name, a code directory location, a code file name, and a code file location in the script code; generating a tree directory structure of the first directory based on the code directory name, the code directory location, the code file name, and the code file location; traversing the tree directory structure, generating the code directory at the code directory location according to the code directory name; and traversing the tree directory structure, and generating the code file at the position of the code file according to the code file name.
In this embodiment of the present disclosure, the code creating module 601 is further configured to obtain, based on the script code, a code file template corresponding to the type of the code file; and filling codes into the code file based on the code file template.
In an embodiment of the present disclosure, the test case creating module 602 is configured to, in response to detecting a modification operation on the code file template, perform a first modification on the code file based on the modification operation; and carrying out second modification on the test case file based on the first modification.
In the embodiment of the present disclosure, the test case file:
in the directory where the code file is located, or,
and the test case directory is created based on the test case directory name and the test case directory position in the script code.
In this embodiment of the present disclosure, the test case creating module 602 is configured to obtain a corresponding test case template based on the type of the testable code in the code file; and filling test case codes into the test case file based on the test case template.
In the embodiment of the present disclosure, the test case creating module 602 is configured to execute a code test based on the test case file; based on the results of the code test, the problem existing in the code file is corrected.
In this embodiment of the present disclosure, the code creating module 601 is further configured to obtain a corresponding code modification template based on the type of the problem; and correcting the problems in the code file based on the code correction template.
In an embodiment of the present disclosure, the code file further includes at least one of data of an operation interface component, a style of the operation interface, and a code of the operation interface.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, and do not violate the good customs of the public order.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 7 illustrates a schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the device 700 comprises a computing unit 701, which may perform various suitable actions and processes according to a computer program stored in a Read Only Memory (ROM) 702 or a computer program loaded from a storage unit 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Various components in the device 700 are connected to the I/O interface 705, including: an input unit 706 such as a keyboard, a mouse, or the like; an output unit 707 such as various types of displays, speakers, and the like; a storage unit 708 such as a magnetic disk, optical disk, or the like; and a communication unit 709 such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
Computing unit 701 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 701 executes the respective methods and processes described above, such as the creation method of a file. For example, in some embodiments, the file creation method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 708. In some embodiments, part or all of a computer program may be loaded onto and/or installed onto device 700 via ROM 702 and/or communications unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the file creation method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the file creation method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server combining a blockchain.
It should be understood that various forms of the flows shown above, reordering, adding or deleting steps, may be used. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (14)

1. A method of file creation, the method comprising:
in response to the detection of a creation instruction and a first directory name, creating a first directory corresponding to the first directory name based on a pre-written script code, wherein the first directory comprises a code directory and a code file;
and creating a test case file corresponding to the code file based on the script code, wherein the test case file comprises test cases of the testable codes in the code file.
2. The method of claim 1, wherein the script code includes at least one of:
code directory name, code directory location, code file name, code file location.
3. The method of claim 2, wherein creating a first directory corresponding to the first directory name based on pre-written script code comprises:
acquiring a code directory name, a code directory position, a code file name and a code file position in the script code;
generating a tree directory structure of the first directory based on the code directory name, the code directory location, the code file name, and the code file location;
traversing the tree directory structure, generating the code directory at the code directory location from the code directory name;
and traversing the tree directory structure, and generating the code file at the position of the code file according to the code file name.
4. The method of claim 1, wherein after the creating the first directory corresponding to the first directory name, the method further comprises:
acquiring a code file template corresponding to the type of the code file based on the script code;
and filling codes into the code file based on the code file template.
5. The method of claim 4, wherein the method further comprises:
in response to detecting a modification operation on the code file template, making a first modification to the code file based on the modification operation;
and performing second modification on the test case file based on the first modification.
6. The method of claim 1, wherein the test case file:
in the directory where the code file is located, or,
and the test case directory is created based on the test case directory name and the test case directory position in the script code.
7. The method of claim 1, wherein the creating a test case file corresponding to the code file comprises:
acquiring a corresponding test case template based on the type of the testable code in the code file;
and filling test case codes into the test case file based on the test case template.
8. The method of claim 1, wherein after the creating the test case file corresponding to the code file, the method further comprises:
executing a code test based on the test case file;
based on the results of the code test, the problems present in the code file are corrected.
9. The method of claim 8, wherein the correcting the problem in the code file comprises:
acquiring a corresponding code correction template based on the type of the problem;
and correcting the problems in the code file based on the code correction template.
10. The method of claim 1, wherein the code file further comprises at least one of data of an operator interface component, a style of the operator interface, and code of the operator interface.
11. An apparatus for creating a file, the apparatus comprising:
the code creating module is used for creating a first directory corresponding to a first directory name based on a pre-written script code in response to detecting a creating instruction and the first directory name, wherein the first directory comprises a code directory and a code file;
and the test case creating module is used for creating a test case file corresponding to the code file based on the script code, and the test case file comprises a test case of the testable code in the code file.
12. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-10.
13. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-10.
14. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-10.
CN202211136794.5A 2022-09-19 2022-09-19 File creation method and related device Pending CN115686479A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211136794.5A CN115686479A (en) 2022-09-19 2022-09-19 File creation method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211136794.5A CN115686479A (en) 2022-09-19 2022-09-19 File creation method and related device

Publications (1)

Publication Number Publication Date
CN115686479A true CN115686479A (en) 2023-02-03

Family

ID=85062557

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211136794.5A Pending CN115686479A (en) 2022-09-19 2022-09-19 File creation method and related device

Country Status (1)

Country Link
CN (1) CN115686479A (en)

Similar Documents

Publication Publication Date Title
CN111241454B (en) Method, system and device for generating webpage codes
US8490050B2 (en) Automatic generation of user interfaces
CN111125064B (en) Method and device for generating database schema definition statement
US11422783B2 (en) Auto-deployment of applications
CN115509522A (en) Interface arranging method and system for low-code scene and electronic equipment
CN116028028A (en) Request function generation method, device, equipment and storage medium
CN112988578A (en) Automatic testing method and device
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN116009847A (en) Code generation method, device, electronic equipment and storage medium
CN115618777A (en) File generation method, device, equipment and storage medium
CN115509602A (en) Project management method, device, equipment and storage medium
CN115686479A (en) File creation method and related device
CN111221610B (en) Page element acquisition method and device
CN114579466A (en) Method, device, equipment and medium for constructing test case and code test
CN114741294A (en) Page debugging method, device, equipment and storage medium
CN114579120A (en) Application code processing method and device, electronic equipment and storage medium
CN117573561B (en) Automatic test system, method, electronic equipment and storage medium
CN114647419A (en) Service deployment processing method and device, electronic equipment and storage medium
CN117667112A (en) Self-adaptive generation method of front-end development document based on babel
CN115525295A (en) Automatic code editing method and device, electronic equipment and storage medium
CN117632710A (en) Method, device, equipment and storage medium for generating test code
CN116974940A (en) Interface testing method, device, equipment and storage medium
CN115268880A (en) Code generation method and device, electronic equipment and storage medium
CN115509932A (en) Interface test case generation method, device, equipment and medium
CN112559311A (en) Interface adaptation method and device for automatic testing of mobile terminal

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