CN114647565A - Android project testing method, storage medium and electronic device - Google Patents

Android project testing method, storage medium and electronic device Download PDF

Info

Publication number
CN114647565A
CN114647565A CN202011503449.1A CN202011503449A CN114647565A CN 114647565 A CN114647565 A CN 114647565A CN 202011503449 A CN202011503449 A CN 202011503449A CN 114647565 A CN114647565 A CN 114647565A
Authority
CN
China
Prior art keywords
android
test
target
file
application
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
CN202011503449.1A
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.)
Huizhou BYD Electronic Co Ltd
Original Assignee
Huizhou BYD Electronic 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 Huizhou BYD Electronic Co Ltd filed Critical Huizhou BYD Electronic Co Ltd
Priority to CN202011503449.1A priority Critical patent/CN114647565A/en
Publication of CN114647565A publication Critical patent/CN114647565A/en
Pending legal-status Critical Current

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure relates to an android project testing method, a storage medium and an electronic device, wherein a source code of an android project to be tested can be obtained through a server, and a target code is obtained after the source code of the android project to be tested is compiled, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system; sending the target code to target android equipment through a terminal so that the target android equipment can be refreshed according to the target code; after the target android device finishes flashing, determining a target android application from at least one to-be-tested android application; generating a first test file under a first directory corresponding to the target android application, wherein the first test file comprises a test source code for testing the target android application; and under the condition of receiving a test instruction sent by the terminal, testing the target android application through an atest command line tool according to the first test file.

Description

Android project testing method, storage medium and electronic device
Technical Field
The disclosure relates to the field of android system testing, in particular to an android project testing method, a storage medium and electronic equipment.
Background
The android system or the android application is inevitably tested in the development process of the android system and the android application, the testing of the android application code in the related technology mainly comprises the steps of compiling a unit test case in the android studio by using test frames such as junit and powermock and manually executing the unit test case, but when the unit test is carried out in the android studio, the testing code is compiled on a local computer, and the system of the local computer is usually a Windows system and not an android system, so that the android application code depending on the android system in the android application cannot be tested. In addition, because the test system needs to manually compile all test codes and manually click to run the test, the operation is more complicated, and the test speed and efficiency are lower.
Disclosure of Invention
The purpose of the disclosure is to provide a test method, a storage medium and an electronic device for an android project.
In a first aspect, a method for testing an android project is provided, which is applied to a server, and the method includes: the method comprises the steps of obtaining a source code of an android project to be tested, compiling the source code of the android project to be tested to obtain a target code, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system; sending the target code to target android equipment through a terminal so that the target android equipment can be refreshed according to the target code; after the target android device is refreshed, determining a target android application from at least one android application to be tested; generating a first test file under a first directory corresponding to the target android application, wherein the first test file comprises a test source code for testing the target android application; and under the condition of receiving a test instruction sent by the terminal, testing the target android application through an atest command line tool according to the first test file.
Optionally, the obtaining the source code of the android project to be tested includes: receiving directory information of the android project to be tested, which is sent by the terminal; and determining the source code of the android project to be tested according to the directory information.
Optionally, the generating a first test file under a first directory corresponding to the target android application includes: adding a test directory under the first directory; acquiring a source code file, a configuration file and a compiling file of the target android application in the first directory; generating a template file under the newly added test directory according to the source code file, the configuration file and the compiling file, wherein the template file comprises common source codes used in android application test; and receiving a modification instruction of a user for the template file, and modifying the template file according to the modification instruction to obtain the first test file.
Optionally, the testing the target android application through the atest command line tool according to the first test file includes: acquiring an application identifier of the target android application; generating a target atest command through the atest command line tool according to the application identifier; compiling the test source code by executing the target atest command to obtain a target test code; and converting the target test code into an android Application Package (APK) file, and sending the APK file to the target android equipment through the terminal so as to test the target android application by running the APK file on the target android equipment.
Optionally, the android project to be tested further includes a framework code of the android system; the method further comprises the following steps: determining a second directory corresponding to the target frame code to be tested; generating a second test file for testing the target frame code under the second directory; and testing the target frame code through the atest command line tool according to the second test file.
Optionally, the method further comprises: under the condition that a test report generation instruction sent by the terminal is received, generating a test report according to a test log file, wherein the test log file is a test process file generated when the server executes an atest command for testing; the test report is used for recording the path of the test case which fails the test and the failure reason.
In a second aspect, a method for testing an android project is provided, which is applied to a terminal, and the method includes: acquiring directory information of an android project to be tested, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system; sending the directory information to a server so that the server can determine the source code of the android project to be tested according to the directory information, and conducting flash on target android equipment after compiling the source code of the android project to be tested; determining a target android application selected by a user in at least one android application to be tested according to a trigger operation of the user, and sending an application identifier of the target android application to the server, so that the server determines the target android application according to the application identifier and generates a first test file under a first directory corresponding to the target android application, wherein the first test file comprises a test source code for testing the target android application; and sending a test instruction to the server according to the triggering operation of the user, so that the server tests the target android application through an atest command line tool according to the first test file under the condition that the server receives the test instruction.
Optionally, after the sending the application identifier of the target android application to the server, the method further includes: reading a template file on the server, and generating a modification instruction for modifying the template file according to a trigger operation of a user, wherein the template file comprises common source codes used when testing android applications generated by the server; and sending the modification instruction to the server so that the server modifies the template file according to the modification instruction to obtain the first test file.
Optionally, after the test instruction is sent to the server according to the trigger operation of the user, the method further includes: receiving the APK file sent by the server, sending the APK file to the target android device so as to test the target android application by running the APK file on the target android device, wherein the APK file is that the server compiles the test source code by executing a target atest command after receiving the test instruction to obtain a target test code, and then the target test code is converted to obtain a file, and the target atest command is an atest command generated by the atest command line tool according to the application identifier of the target android application.
Optionally, the method further comprises: sending a test report generation instruction to the server according to a trigger operation of a user, so that the server generates a test report according to a test log file under the condition of receiving the test report generation instruction, wherein the test log file is a test process file generated when the server executes an atest command for testing; the test report is used for recording the path of the test case which fails the test and the failure reason.
In a third aspect, a computer readable storage medium is provided, on which a computer program is stored, which program, when being executed by a processor, carries out the steps of the method according to the first aspect of the disclosure.
In a fourth aspect, an electronic device is provided, comprising: a memory having a computer program stored thereon; a processor for executing the computer program in the memory to implement the steps of the method of the first aspect of the disclosure.
In a fifth aspect, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to the second aspect of the disclosure.
In a sixth aspect, an electronic device is provided, comprising: a memory having a computer program stored thereon; a processor for executing the computer program in the memory to implement the steps of the method of the second aspect of the present disclosure.
According to the technical scheme, the source code of the android project to be tested can be obtained through the server, and the target code is obtained after the source code of the android project to be tested is compiled, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system; then sending the target code to target android equipment through a terminal so that the target android equipment can be refreshed according to the target code; after the target android device finishes flashing, determining a target android application from at least one to-be-tested android application; generating a first test file under a first directory corresponding to the target android application; under the condition that the test instruction sent by the terminal is received, the target android application is tested through an atest command line tool according to the first test file, so that the android application to be tested and the source codes of the android system depended on by the android application to be tested can be compiled and then burnt to the target android device together, the problem that part of android application codes depended on the android system in the correlation technology cannot be tested is solved, the first test file for testing the target android application can be generated at the specified position (namely the first directory) corresponding to the target android application to be tested, the flow and the steps of manual operation are reduced, and the test efficiency is improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a schematic diagram illustrating a scenario interaction of an android project testing system in accordance with an illustrative embodiment;
FIG. 2 is a schematic diagram illustrating an interface structure of an android project testing platform, in accordance with an illustrative embodiment;
FIG. 3 is a flow diagram illustrating a first method of android project testing, in accordance with an illustrative embodiment;
FIG. 4 is a flowchart illustrating a second method of android project testing, in accordance with an exemplary embodiment;
FIG. 5 is a flowchart illustrating a third method of android project testing, in accordance with an illustrative embodiment;
FIG. 6 is a block diagram illustrating the structure of an electronic device in accordance with an exemplary embodiment;
fig. 7 is a block diagram illustrating another electronic device according to an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Firstly, introducing an application scenario of the method, wherein the method is mainly applied to a scenario of testing framework layer (also called framework layer) codes of android applications and android systems, and in the related technology, the testing of the android application codes mainly comprises the steps of compiling unit test cases in an android studio by using test frameworks such as junit and powermock and manually executing the unit test cases; the scheme for testing the framework layer code of the android system is as follows: establishing an Android application project, placing a source code of a testing method written based on a junit and mockito testing framework in a source code directory of the application, executing a testing command by using an atest command line tool on a server side, specifically, compiling a framework layer source code to be tested by executing the atest command, then generating an Android Application Package (APK), and installing the APK on Android equipment for debugging through an Android Debug Bridge (ADB), so as to execute the testing method in the source code on the Android equipment.
However, when the unit test is performed in the android studio, because the test code is written on the local computer, and the system of the local computer is usually a Windows system, not an android system, the android application code depending on the android system in the android application cannot be tested. In addition, because all test codes need to be manually written and the test needs to be manually clicked and operated, the operation is complicated, and the test speed and efficiency are low.
In addition, in the related art, in the process of testing the framework layer code of the android system by executing the atest command, if a plurality of modules included in the framework layer code are to be tested, a directory where the test modules are located needs to be manually opened one by one to create a new test file, the operation is complicated, and android equipment needs to be connected when the atest command is executed, a server is usually far away from an office area, the plugging and unplugging of the equipment are inconvenient, and the equipment is not convenient to manage and maintain.
In order to solve the existing problems, the present disclosure provides an android project testing method, which can be applied to a server configured with a testing platform, where the testing platform can be used to test an android application and a frame code of an android system, that is, the android project in the present disclosure includes the frame code of the android application and/or the android system, specifically, a source code of an android project to be tested can be obtained through the server, and a target code is obtained after the source code of the android project to be tested is compiled, where the android project to be tested includes the android system and at least one android application to be tested on the android system; then sending the target code to target android equipment through the terminal so that the target android equipment can be refreshed according to the target code; after the target android device finishes flashing, determining a target android application from at least one to-be-tested android application; generating a first test file under a first directory corresponding to the target android application; under the condition of receiving a test instruction sent by the terminal, testing the target android application through an atest command line tool according to the first test file, so that the source codes of the android application to be tested and the android system depended by the android application to be tested can be compiled and then burnt to the target android device together, the problem that part of android application codes depended on the android system in the correlation technique cannot be tested is solved, the first test file for testing the target android application can be generated at the specified position (namely the first directory) corresponding to the target android application to be tested, the flow and the steps of manual operation are reduced, and the test efficiency is improved.
To facilitate understanding of the present solution, an implementation environment and a testing process of the android project testing method provided by the present disclosure are first introduced.
Fig. 1 is a schematic view illustrating a scenario interaction of an android project testing system according to an exemplary embodiment, as shown in fig. 1, the android project testing system includes an android device (e.g., a hardware device using the android system, such as a mobile phone, an IPAD, etc.), a terminal (generally referred to as a local computer), and a server, where the android device and the terminal may communicate with each other through a Universal Serial Bus (USB), and the terminal and the server may communicate with each other remotely through a Secure Shell (SSH).
The server is provided with a test platform for testing android applications and framework codes of an android system in advance, a server where the test platform is located is provided with an android compiling environment and an ADB, the test platform is built based on a web technology, fig. 2 is an interface structure schematic diagram of an android project test platform shown according to an exemplary embodiment, and as shown in fig. 2, the platform has the functions of android project directory analysis, USB sharing, SSH remote connection, tested module selection, test command generation and execution, test report generation and downloading and the like; a user can log in the test platform through a terminal, then, triggering operation of android project test can be performed in a test platform interface shown in fig. 2, a server can compile source codes of an android project to be tested according to the triggering operation of the user on the test platform interface on the terminal, and send compiled target codes to target android equipment through the terminal, so that the target android equipment can perform flashing according to the target codes, the server can also generate test source codes (namely, the first test files) for testing the target android application under a first directory corresponding to the target android application, and generate APK files after compiling the test source codes by running an atest command; the target android device is used for running the android application package on the target android device to realize the test of the android project after receiving the android application package (namely the APK file) sent by the server through the terminal.
Specific embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
FIG. 3 is a flowchart illustrating a method for android project testing, which may be applied to a server, according to an example embodiment, and includes the following steps:
in step S301, a source code of the android project to be tested is obtained, and a target code is obtained after the source code of the android project to be tested is compiled, where the android project to be tested includes an android system and at least one android application to be tested on the android system.
The android Application may include Application programs such as a short message program, a calendar, a map, a browser, a contact management program, and the like, and in general, the android system is divided into four layers from bottom to top, which are a Linux Kernel, a middleware (i.e., android C/C + + Framework), an Application Framework (Application Framework), and an Application (Applications), where each layer encapsulates the bottom layer and exposes a call interface to the top layer. In the present disclosure, the android project to be tested may further include a framework code of the android system, and thus, the framework code of the android system and the android application may be tested by using the method provided in the present disclosure.
In this step, the directory information of the android project to be tested, which is sent by the terminal, can be received; and determining the source code of the android project to be tested according to the directory information.
In a possible implementation scenario, a user can log in a test platform on a terminal, and share android devices (such as hardware android devices like a mobile phone and an IPAD (internet protocol ad)) connected to the terminal to a server through a USB (universal serial bus) sharing function on the test platform, wherein the user can enter a test platform interface shown in fig. 2 after logging in the test platform, then perform corresponding test trigger operation on the test platform interface, and input a directory where an android item to be tested is located in the test platform interface after logging in the test platform, at this moment, the terminal can acquire directory information of the android item to be tested, and send the directory information to the server, so that the server can receive the directory information.
In addition, source codes of different android items and source codes of android applications carrying the android system are stored in different directories on the server side in advance, so that the server can acquire the source codes of the android items to be detected according to the directory information after acquiring the directory information of the android items to be detected, which is sent by the terminal.
In step S302, the target code is sent to the target android device through the terminal, so that the target android device performs flashing according to the target code.
The target android device can include android devices which are selected by a user in advance in a test interface of a test platform of the terminal and used for testing the android item to be tested.
In step S303, after the target android device completes the flash, the target android application is determined from at least one to-be-tested android application.
The target android application is selected from at least one android application to be tested by a user and is the android application to be tested currently.
In step S304, a first test file is generated under a first directory corresponding to the target android application, where the first test file includes a test source code for testing the target android application.
In this step, a first test directory may be newly added under the first directory; acquiring a first source code file, a first configuration file and a first compiling file of the target android application under the first directory; generating a first template file under the first test directory according to the first source code file, the first configuration file and the first compiling file, wherein the first template file comprises common source codes used in android application test; and receiving a modification instruction of a user for the first template file, and modifying the first template file according to the modification instruction to obtain the first test file.
In step S305, when a test instruction sent by the terminal is received, the target android application is tested by the atest command line tool according to the first test file.
In this step, an application identifier of the target android application can be obtained; generating a target atest command through the atest command line tool according to the application identifier; compiling the test source code by executing the target atest command to obtain a target test code; and converting the target test code into an android Application Package (APK) file, and sending the APK file to the target android device through the terminal so as to test the target android application by running the APK file on the target android device.
By adopting the method, the server can compile the android application to be tested and the source codes of the android system depended by the android application to be tested and then burn the compiled android application to the target android device, so that the problem that part of android application codes depended on the android system in the correlation technique cannot be tested is solved, the first test file for testing the target android application can be generated at the specified position (namely the first directory) corresponding to the target android application to be tested, the flow and the steps of manual operation are reduced, and the test efficiency is improved.
Fig. 4 is a flowchart illustrating an android project testing method, which may be applied to a terminal (e.g., a local computer), according to an exemplary embodiment, and as shown in fig. 4, the method includes the following steps:
in step S401, directory information of an android project to be tested is obtained, where the android project to be tested includes an android system and at least one android application to be tested on the android system.
The android application can comprise application programs such as a short message program, a calendar, a map, a browser and a contact management program, the android project to be tested can further comprise a frame code of an android system, and therefore the frame code of the android system and the android application can be tested by the method provided by the disclosure.
In step S402, the directory information is sent to a server, so that the server determines the source code of the to-be-tested android project according to the directory information, and performs flashing on the target android device after compiling the source code of the to-be-tested android project.
The target android device can comprise an android device which is selected in advance in a test interface of a test platform of the terminal by a user and used for testing the android project to be tested.
In step S403, a target android application selected by the user from at least one to-be-tested android application is determined according to the user trigger operation, and an application identifier of the target android application is sent to the server, so that the server determines the target android application according to the application identifier, and generates a first test file in a first directory corresponding to the target android application.
The target android application is selected from at least one android application to be tested by a user and is the android application to be tested currently.
After the step is executed, the terminal can read a first template file on the server, and generates a modification instruction for modifying the first template file according to the triggering operation of the user, wherein the first template file comprises common source codes used when testing android applications generated by the server; and sending the modification instruction to the server so that the server modifies the first template file according to the modification instruction to obtain the first test file.
In step S404, a test instruction is sent to the server according to a trigger operation of a user, so that the server tests the target android application through an atest command line tool according to the first test file when receiving the test instruction.
After the step is executed, the terminal may receive the APK file sent by the server, and send the APK file to the target android device, so as to test the target android application by running the APK file on the target android device, where the APK file is an atest command generated by the application identifier of the target android application through the atest command line tool, and the APK file is obtained by compiling the test source code by executing a target atest command after the server receives the test instruction, and obtaining a target test code by converting the target test code.
By adopting the method, the android application to be tested and the source code of the android system depended by the android application to be tested can be compiled and then burnt into the target android device together, so that the problem that part of android application codes depended on the android system in the correlation technique cannot be tested is solved, and the first test file for testing the target android application can be generated at the designated position (namely the first directory) corresponding to the target android application to be tested, so that the flow and steps of manual operation are reduced, and the test efficiency is improved.
Fig. 5 is an interaction diagram of an android project testing method according to an exemplary embodiment, in this embodiment, the terminal is used as a local computer, and an example of testing an android application and a framework code of an android system at the same time is described, as shown in fig. 5, the method includes the following steps:
in step S501, the local computer obtains directory information of the to-be-tested android project, and sends the directory information to the server.
The Android project to be tested comprises an Android system and at least one Android Application to be tested on the Android system, the Android Application can comprise short message programs, calendars, maps, browsers, contact management programs and other Application programs, under the general condition, the Android system is divided into four layers from bottom to top, namely a Linux Kernel, a middleware (namely a C/C + + frame of Android), an Application frame (Application Framework) and Application programs (Applications), and each layer encapsulates the bottom layer and exposes a calling interface to the upper layer.
In a possible implementation scenario, a user may log in a test platform on a local computer, and share android devices (such as hardware android devices like a mobile phone and an IPAD) connected to the local computer to a server through a USB sharing function on the test platform, wherein the user may enter a test platform interface shown in fig. 2 after logging in the test platform, and then perform a corresponding test trigger operation on the test platform interface, and therefore, in this step, the user may input a directory where an android project to be tested is located in the test platform interface after logging in the test platform, at this time, the local computer may obtain directory information of the android project to be tested, and send the directory information to the server.
It should be noted that the android project to be tested usually includes a complete android system to be tested and an android application program carrying the android system, the android systems of different versions are regarded as different android projects, and the android devices corresponding to the different android projects are usually different, for example, the android project to be tested currently may be an android 9.0 and a user self-research android application carrying the android 9.0.
In step S502, the server determines the source code of the to-be-tested android item according to the directory information, and compiles the source code of the to-be-tested android item to obtain an object code.
The source codes of different android projects and the source codes of the android application programs carrying the android systems are stored in the server side under different catalogs in advance, so that the server can acquire the source codes of the to-be-detected android projects according to the catalog information after acquiring the catalog information of the to-be-detected android projects sent by the local computer.
In an actual test scenario, if a source code of the to-be-tested android project is to be run on the android device, the source code needs to be compiled into a binary code that can be recognized by the device, that is, the object code.
In step S503, the server sends the object code to the target android device through the local computer, so that the target android device performs a flash according to the object code.
The target android device can comprise android devices which are selected by a user in advance in a test interface of a test platform of the local computer and used for testing the android project to be tested.
After the step is executed, the android application program to be tested and the android system depended by the android application program can be burned into the target android device, so that the problem that part of android application codes depended on the android system in the correlation technique cannot be tested is solved, the coverage degree of android application program testing is improved, the android application can be tested more comprehensively, and hidden problems can be found.
In step S504, after receiving a flash completion indication message returned by the target android device, the local computer outputs a first prompt message, where the first prompt message is used to prompt a user to select a test module, and the test module includes a target frame code of a target android application and an android system to be tested.
In step S505, the local computer determines the target frame code and the target android application according to the trigger operation of the user, and sends an application identifier of the target android application and a frame identifier corresponding to the target frame code to the server.
For example, the test platform may show, on the interface, a plurality of android applications on an android system to be tested and a plurality of modules of the android system frame code to be tested in a list manner, where different modules correspond to different portions of the frame code, and thus, a user may select, in the list, the target android application and the target frame code that are to be tested through a sliding operation.
In step S506, the server determines the target android application according to the application identifier, determines a target framework code according to the framework identifier, generates a first test file in a first directory corresponding to the target android application, and generates a second test file in a second directory corresponding to the target framework code.
The first test file comprises test source codes for testing the target android application, and the second test file comprises test source codes for testing the target framework codes.
In this step, the server may add a first test directory under the first directory, add a second test directory under the second directory, then obtain a first source code file, a first configuration file and a first compiled file of the target android application under the first directory, obtain a second source code file, a second configuration file and a second compiled file of the target frame code under the second directory, where the source code file includes a source code corresponding to the target android application or the target frame code, the configuration file includes information such as an application authority of the target android application or the target frame code, registration information, and the like, and the compiled file includes a compiling rule for compiling the source code of the target android application or the source code of the target frame code, so that the server may generate a first template file under the first test directory according to the first source code file, the first configuration file and the first compiled file, the first template file comprises common source codes used in android application testing, a second template file is generated under the second testing directory according to the second source code file, the second configuration file and the second compiling file, the second template file comprises common source codes used in android system frame code testing, then, the server can receive modification instructions of a user for the first template file and the second template file, the first template file is modified according to the modification instructions to obtain the first testing file, and the second template file is modified according to the modification instructions to obtain the second testing file.
Therefore, a user can generate codes for testing (for example, Java codes) only by modifying a small amount on the basis of the template file, the complex operation that the user writes the testing codes for each android application to be tested or each part of frame codes one by one is avoided, in addition, the server can automatically add new directories under the directories corresponding to the target android application to be tested and the target frame codes, and automatically generate testing files under the new directories, the flow and the steps of manual operation are reduced, the testing flow is simplified, the time required by testing is shortened, and the testing efficiency can be improved.
In step S507, the local computer sends a test instruction to the server according to the trigger operation of the user, where the test instruction is used to instruct the server to test the target android application and the target frame code through an atest command line tool.
In a possible implementation manner, the local computer may output, to the user, second prompt information when detecting that the user has modified the template file, that is, the executable test code is generated, where the second prompt information is used to prompt the user to select whether to execute the test, and at this time, if the user triggers the test button, the local computer may generate the test instruction according to a trigger operation of the user, and send the test instruction to the server.
In step S508, the server compiles the first test file and the second test file according to the first test file and the second test file by an atest command line tool to generate an APK file when receiving the test instruction, and sends the APK file to the target android device through the local computer.
The APK is an application package file format used by the android system and used for distributing and installing mobile applications and middleware, codes of an android application program are required to be compiled and then packaged into a file which can be identified by the android system to be operated when the codes of the android application program are required to be operated on the android device, and the file format which can be identified by the android system and operated is the APK.
In this step, the server may obtain an application identifier of the target android application, and then generate a target atest command through the atest command line tool according to the application identifier, for example, the target atest command may be atest + application id, so that the server may compile the test source code in the first test file by executing the target atest command to obtain the target test code, and then may convert the target test code into the APK file of the android application package, and similarly, the server may obtain the frame id of the target frame code, then generating a target atest command through the atest command line tool according to the frame identifier, at this time, the target atest command may be atest + frame identifier, in this way, the server can compile the test source code in the second test file by executing the target atest command to obtain a target test code, and then can convert the target test code into an android application package APK file.
In step S509, the local computer receives the APK file sent by the server, and sends the APK file to the target android device, so that the target android application and the target framework code are tested by running the APK file on the target android device.
It should be noted that, a user can log in the testing platform on the local computer to view the execution process of the atest command on the server on the page, so that each testing process can be monitored in real time.
In step S510, the local computer sends a test report generation instruction to the server according to the user' S trigger operation.
The test report generation instruction is used for instructing the server to generate a test report according to a test log file, the test log file is a test process file generated when the server executes an atest command for testing, and the test report is used for recording a path of a test case with test failure and a failure reason.
Considering that in the related art, in the process of testing the framework layer code of the android system by executing the atest command, the test log file can only be generated under the temporary folder of the server, but the test log file is usually printed one by one according to the sequence of the execution time, and the file contains more redundant information without reference value for developers, and cannot be directly used as the test report file, and cannot well provide intuitively useful information and specific positions where errors or exceptions occur for the developers.
In step S511, the server generates a test report from the test log file when receiving the test report generation instruction.
After the test report is generated, a user can download the test report to a local computer through the test platform, so that a developer can determine the specific position of the error or abnormity of the test case with test failure and the failure reason according to the test report, and the software developer can position and modify the problem in time.
By adopting the method, the android application to be tested and the source code of the android system depended by the android application to be tested can be compiled and then burnt into the target android device together, so that the problem that part of android application codes depended on the android system in the correlation technique cannot be tested is solved, and the first test file for testing the target android application can be generated at the designated position (namely the first directory) corresponding to the target android application to be tested, so that the flow and steps of manual operation are reduced, and the test efficiency is improved. In addition, a test report can be generated, so that software developers can timely position and modify problems according to the test report, android equipment connected with a local computer can be shared for a server to use based on a USB (universal serial bus) sharing technology, and the android hardware equipment can be conveniently managed and different equipment can be conveniently switched for tests of different projects.
Fig. 6 is a block diagram illustrating an electronic device 600 according to an example embodiment. As shown in fig. 6, the electronic device 600 may include: a processor 601 and a memory 602. The electronic device 600 may also include one or more of a multimedia component 603, an input/output (I/O) interface 604, and a communications component 605.
The processor 601 is configured to control the overall operation of the electronic device 600, so as to complete all or part of the steps in the android project testing method. The memory 602 is used to store various types of data to support operation at the electronic device 600, such as instructions for any application or method operating on the electronic device 600 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and so forth. The Memory 602 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk. The multimedia components 603 may include screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 602 or transmitted through the communication component 605. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 604 provides an interface between the processor 601 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 605 is used for wired or wireless communication between the electronic device 600 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 605 may therefore include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 600 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described android project testing method.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the above-described android project testing method. For example, the computer readable storage medium may be the memory 602 described above that includes program instructions executable by the processor 601 of the electronic device 600 to perform the android project testing method described above.
Fig. 7 is a block diagram illustrating an electronic device 700 in accordance with an example embodiment. For example, the electronic device 700 may be provided as a server. Referring to fig. 7, an electronic device 700 includes a processor 722, which may be one or more in number, and a memory 732 for storing computer programs that are executable by the processor 722. The computer program stored in memory 732 may include one or more modules that each correspond to a set of instructions. Further, the processor 722 may be configured to execute the computer program to perform the android project testing method described above.
Additionally, the electronic device 700 may also include a power component 726 that may be configured to perform power management of the electronic device 700 and a communication component 750 that may be configured to enable communication, e.g., wired or wireless communication, of the electronic device 700. The electronic device 700 may also include input/output (I/O) interfaces 758. The electronic device 700 may operate based on an operating system, such as Windows Server, stored in the memory 732TM,Mac OS XTM,UnixTM,LinuxTMAnd so on.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the above-described android project testing method. For example, the computer readable storage medium may be the memory 732 described above including program instructions that are executable by the processor 722 of the electronic device 700 to perform the android project testing method described above.
In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described android project testing method when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (14)

1. A method for testing an android project is applied to a server, and comprises the following steps:
the method comprises the steps of obtaining a source code of an android project to be tested, compiling the source code of the android project to be tested to obtain a target code, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system;
sending the target code to target android equipment through a terminal so that the target android equipment can be refreshed according to the target code;
after the target android device finishes flashing, determining a target android application from at least one to-be-tested android application;
generating a first test file under a first directory corresponding to the target android application, wherein the first test file comprises a test source code for testing the target android application;
and under the condition that a test instruction sent by the terminal is received, testing the target android application through an atest command line tool according to the first test file.
2. The method of claim 1, wherein the obtaining the source code of the android project to be tested comprises:
receiving directory information of the android project to be tested, which is sent by the terminal;
and determining the source code of the android project to be tested according to the directory information.
3. The method of claim 1, wherein generating the first test file under the first directory corresponding to the target android application comprises:
newly adding a first test directory under the first directory;
acquiring a first source code file, a first configuration file and a first compiling file of the target android application under the first directory;
generating a first template file under the first test directory according to the first source code file, the first configuration file and the first compiling file, wherein the first template file comprises common source codes used in android application test;
and receiving a modification instruction of a user for the first template file, and modifying the first template file according to the modification instruction to obtain the first test file.
4. The method of claim 1, wherein the testing the target android application with an atest command line tool according to the first test file comprises:
acquiring an application identifier of the target android application;
generating a target atest command through the atest command line tool according to the application identifier;
compiling the test source code by executing the target atest command to obtain a target test code;
and converting the target test code into an android Application Package (APK) file, and sending the APK file to the target android equipment through the terminal so as to test the target android application by running the APK file on the target android equipment.
5. The method of claim 1, wherein the android project under test further comprises a framework code of the android system; the method further comprises the following steps:
determining a second directory corresponding to the target frame code to be tested;
generating a second test file for testing the target frame code under the second directory;
and testing the target frame code through the atest command line tool according to the second test file.
6. The method according to any one of claims 1 to 5, further comprising:
under the condition that a test report generation instruction sent by the terminal is received, generating a test report according to a test log file, wherein the test log file is a test process file generated when the server executes an atest command for testing; the test report is used for recording the path of the test case which fails the test and the failure reason.
7. An android project testing method is applied to a terminal, and the method comprises the following steps:
acquiring directory information of an android project to be tested, wherein the android project to be tested comprises an android system and at least one android application to be tested on the android system;
sending the directory information to a server so that the server can determine the source code of the android project to be tested according to the directory information, and conducting flash on target android equipment after compiling the source code of the android project to be tested;
determining a target android application selected by a user in at least one android application to be tested according to a trigger operation of the user, and sending an application identifier of the target android application to the server, so that the server determines the target android application according to the application identifier and generates a first test file under a first directory corresponding to the target android application, wherein the first test file comprises a test source code for testing the target android application;
and sending a test instruction to the server according to the triggering operation of the user, so that the server tests the target android application through an atest command line tool according to the first test file under the condition that the server receives the test instruction.
8. The method of claim 7, wherein after the sending the application identification of the target android application to the server, the method further comprises:
reading a first template file on the server, and generating a modification instruction for modifying the first template file according to a trigger operation of a user, wherein the first template file comprises common source codes used when testing android applications generated by the server;
and sending the modification instruction to the server so that the server modifies the first template file according to the modification instruction to obtain the first test file.
9. The method according to claim 7, wherein after the sending of the test instruction to the server according to the triggering operation of the user, the method further comprises:
receiving the APK file sent by the server, sending the APK file to the target android device so as to test the target android application by running the APK file on the target android device, wherein the APK file is that the server compiles the test source code by executing a target atest command after receiving the test instruction to obtain a target test code, and then the target test code is converted to obtain a file, and the target atest command is an atest command generated by the atest command line tool according to the application identifier of the target android application.
10. The method according to any one of claims 7-9, further comprising:
sending a test report generation instruction to the server according to a trigger operation of a user, so that the server generates a test report according to a test log file under the condition of receiving the test report generation instruction, wherein the test log file is a test process file generated when the server executes an atest command for testing; the test report is used for recording the path of the test case which fails the test and the failure reason.
11. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
12. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 6.
13. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 7 to 10.
14. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 7 to 10.
CN202011503449.1A 2020-12-17 2020-12-17 Android project testing method, storage medium and electronic device Pending CN114647565A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011503449.1A CN114647565A (en) 2020-12-17 2020-12-17 Android project testing method, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011503449.1A CN114647565A (en) 2020-12-17 2020-12-17 Android project testing method, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN114647565A true CN114647565A (en) 2022-06-21

Family

ID=81991119

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011503449.1A Pending CN114647565A (en) 2020-12-17 2020-12-17 Android project testing method, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN114647565A (en)

Similar Documents

Publication Publication Date Title
US10841185B2 (en) Platform-integrated IDE
US9886375B2 (en) Automated execution of functional test scripts on a remote system within a unit testing framework
US10698797B2 (en) Mobile application program testing method, server, terminal, and storage medium
US20100313185A1 (en) Access to test-ready virtual environments
CN105338110A (en) Remote debugging method, platform and server
CN111740948B (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CA2698066A1 (en) System and method for remotely compiling multi-platform native applications for mobile devices
CN112882700A (en) iOS application program construction method and device, electronic equipment and storage medium
CN111767208B (en) Automatic test method and device
CN112416318B (en) Micro-service development method and device, storage medium and electronic equipment
CN108614767A (en) A kind of remote debugging method and device
CN112379940B (en) Executable file processing method and device, electronic equipment and storage medium
CN114297056A (en) Automatic testing method and system
CN113986270B (en) Distributed application deployment method and device, storage medium and electronic equipment
KR20180061589A (en) Software build system and software build method using the system
CN111651232A (en) One-machine multi-control method, device and system and electronic equipment
CN112506793A (en) Embedded software unit testing method, system, readable medium and electronic equipment
CN111488275B (en) UI (user interface) automatic testing method and device, storage medium and electronic equipment
CN116627850A (en) Function debugging method and device, storage medium and electronic equipment
CN114546823B (en) Method for reproducing debug scenario of logic system design and related equipment
CN114647565A (en) Android project testing method, storage medium and electronic device
CN105339974B (en) Analog sensor
CN114968644A (en) System software dump method and device, electronic equipment and readable storage medium
CN112925698B (en) Test script generation method and integrated development environment
CN113986263A (en) Code automation test method, device, electronic equipment and storage medium

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