CN114490307A - Unit testing method, device and storage medium - Google Patents

Unit testing method, device and storage medium Download PDF

Info

Publication number
CN114490307A
CN114490307A CN202011259954.6A CN202011259954A CN114490307A CN 114490307 A CN114490307 A CN 114490307A CN 202011259954 A CN202011259954 A CN 202011259954A CN 114490307 A CN114490307 A CN 114490307A
Authority
CN
China
Prior art keywords
test
tested
application
test case
target
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
CN202011259954.6A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202011259954.6A priority Critical patent/CN114490307A/en
Publication of CN114490307A publication Critical patent/CN114490307A/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/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application relates to cloud technology, and provides a unit testing method, a unit testing device and a storage medium, wherein the method comprises the following steps: determining an application to be tested in an uninstalled state in a terminal; starting a preset hot updating plug-in the application to be tested, and carrying out hot updating on the application to be tested based on the hot updating plug-in so as to obtain an updating file from a server, wherein the updating file is a tested program associated with the application to be tested; acquiring a target test case from the application to be tested; loading the target test case, and executing the target test case to perform unit test on the tested program to obtain a test report; and uploading the test report to the server. The scheme can improve the unit testing efficiency, simplify the steps of unit testing, get rid of the trouble that the application needs to be tested repeatedly and the permission box of the application needs to be opened every time when the case is executed every time, and enable the tested terminal to be completely separated from the computer end to execute the unit testing.

Description

Unit testing method, device and storage medium
Technical Field
The embodiment of the application relates to the technical field of cloud, in particular to a unit testing method and device and a storage medium.
Background
In the unit test (for example, gts and cts automated tests) of an android mobile phone, generally, an android test case code and a tested code are respectively packaged into an apk file (namely, a test app and a tested app), and then a computer and the mobile phone to be tested are connected through a data line. The method comprises the steps of connecting a mobile phone through a data line, installing a test app on a computer, installing a tested app on the mobile phone, calling the mobile phone to perform unit test on the tested app, and finally outputting a test report.
Therefore, in each unit test flow, the test app needs to be installed on the computer again, and the tested app needs to be installed on each tested mobile phone, so that the installation of the tested app and the execution of the unit test in the current unit test flow cannot be separated from the operation of the computer, the test convenience is reduced, the test efficiency is reduced, and the problem is more prominent particularly when a plurality of mobile phones are tested in batches.
Disclosure of Invention
The embodiment of the application provides a unit testing method, a unit testing device and a storage medium, which can improve unit testing efficiency, simplify the steps of unit testing, get rid of the trouble that each execution case needs to repeatedly test an application and each time an authority pop-up box of the application is opened, and enable a tested terminal to be completely separated from a computer end to execute unit testing.
In a first aspect, an embodiment of the present application provides a unit testing method, where the method includes:
determining an application to be tested in an uninstalled state in a terminal;
starting a preset hot updating plug-in the application to be tested, and carrying out hot updating on the application to be tested based on the hot updating plug-in so as to obtain an updating file from a server, wherein the updating file is a tested program associated with the application to be tested;
acquiring a target test case from the application to be tested;
loading the target test case, and executing the target test case to perform unit test on the tested program to obtain a test report;
and uploading the test report to the server.
In a second aspect, an embodiment of the present application provides a unit testing apparatus having a function of implementing a unit testing method corresponding to the second aspect. The functions can be realized by hardware, and the functions can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above functions, which may be software and/or hardware.
In one possible design, the unit testing apparatus includes a processing module, a transceiver module, and a loading module:
the processing module is used for determining the application to be tested in the non-installed state in the terminal; starting a preset hot updating plug-in the application to be tested, carrying out hot updating on the application to be tested based on the hot updating plug-in, and acquiring an updating file from a server through the transceiver module, wherein the updating file is a tested program associated with the application to be tested; acquiring a target test case from the application to be tested;
the loading module is used for loading the target test case;
the processing module is further used for executing the target test case to perform unit test on the tested program to obtain a test report; and uploading the test report to the server through the transceiver module.
In one possible design, a dynamic loader and a test request class are preset in the application to be tested; the processing module is specifically configured to:
starting the dynamic loader to dynamically analyze the installation package file of the application to be tested according to a dynamic loading mode so as to acquire test case information from the installation package file, wherein the test case information comprises the name of a test case package, the name of a test class and the name of a test mode;
adding the test case information into the test request class;
determining a test path for testing the tested program according to the test request class, and determining a case name of the target test case for testing the tested program;
and acquiring the target test case according to the case name.
In a further aspect, embodiments of the present application provide a computer apparatus, such as a unit testing apparatus, comprising at least one connected processor, a memory and a transceiver, wherein the memory is used for storing a computer program, and the processor is used for calling the computer program in the memory to execute the method of the first aspect.
Yet another aspect of the embodiments of the present application provides a computer-readable storage medium, which includes instructions that, when executed on a computer, cause the computer to perform the method of the first aspect.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the first aspect described above.
Compared with the prior art, in the scheme provided by the embodiment of the application, the application to be tested can be subjected to hot update by starting the preset hot update plug-in the application to be tested to obtain the update file, and the update file obtained from the server is the program to be tested associated with the application to be tested, so the program to be tested is obtained in an update mode without repeatedly installing the application to be tested. And acquiring a target test case from the application to be tested, loading the target test case, and executing the target test case to perform unit test on the program to be tested to obtain a test report. Therefore, on one hand, the tested terminal can be completely separated from a test case of a computer end execution unit test or a white box test, and the problem of battery aging caused by long-time connection of the mobile phone to the computer can be effectively reduced from the hardware perspective; on the other hand, compared with the prior art, in addition, when the application to be tested is installed on the terminal, the popup frames irrelevant to the unit test (such as the installation popup frame, the permission popup frame, and the like) can be generated, and only the popup frames can be manually processed, so that the real automatic processing can not be realized, and the test efficiency is reduced. The embodiment of the application can effectively simplify the steps of unit testing, and get rid of the trouble that the application needs to be tested repeatedly when the case is executed each time and the permission box of the application is opened each time.
Drawings
FIG. 1a is a schematic flow chart of a unit test based on a system framework according to an embodiment of the present application;
FIG. 1b is a schematic flow chart of another embodiment of the present application for performing unit testing based on a system framework;
FIG. 2 is a schematic flow chart of a unit testing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a unit testing apparatus according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a unit testing apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a mobile phone in an embodiment of the present application.
Detailed Description
The terms "first," "second," and the like in the description and in the claims of the embodiments of the application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprise" and "have," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules expressly listed, but may include other steps or modules not expressly listed or inherent to such process, method, article, or apparatus, such that the division of modules presented in the present application is merely a logical division and may be implemented in a practical application in a different manner, such that multiple modules may be combined or integrated into another system or some features may be omitted or not implemented, and such that couplings or direct couplings or communicative connections shown or discussed may be through interfaces, indirect couplings or communicative connections between modules may be electrical or the like, the embodiments of the present application are not limited. Moreover, the modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed in a plurality of circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
The embodiment of the application provides a unit testing method, a unit testing device and a storage medium, which can be used for automatic unit testing. This scheme can be used at the terminal side.
The scheme of the embodiment of the present application can be implemented based on Cloud technology (Cloud technology), and the following technical fields related to Cloud computing, Cloud storage, databases, and the like in the Cloud technology are respectively introduced: .
The cloud technology is a hosting technology for unifying series resources such as hardware, software, network and the like in a wide area network or a local area network to realize the calculation, storage, processing and sharing of data. Cloud technology (Cloud technology) is based on a general term of network technology, information technology, integration technology, management platform technology, application technology and the like applied in a Cloud computing business model, can form a resource pool, is used as required, and is flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture-like websites and more web portals. With the high development and application of the internet industry, each article may have its own identification mark and needs to be transmitted to a background system for logic processing, data in different levels are processed separately, and various industrial data need strong system background support and can only be realized through cloud computing. The embodiment of the application can issue network configuration (such as first network configuration and subsequent update network configuration) to the network equipment through the cloud technology
A distributed cloud storage system (hereinafter, referred to as a storage system) refers to a storage system that integrates a large number of storage devices (storage devices are also referred to as storage nodes) of different types in a network through application software or application interfaces to cooperatively work by using functions such as cluster application, grid technology, and a distributed storage file system, and provides a data storage function and a service access function to the outside. In the embodiment of the application, information such as network configuration, configuration examples, configuration models, conversion templates, divided network areas and the like can be stored in the database, so that the server can conveniently call the information.
At present, a storage method of a storage system is as follows: logical volumes are created, and when created, each logical volume is allocated physical storage space, which may be the disk composition of a certain storage device or of several storage devices. The client stores data on a certain logical volume, that is, the data is stored on a file system, the file system divides the data into a plurality of parts, each part is an object, the object not only contains the data but also contains additional information such as data identification (ID, ID entry), the file system writes each object into a physical storage space of the logical volume, and the file system records storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.
The process of allocating physical storage space for the logical volume by the storage system specifically includes: physical storage space is divided in advance into stripes according to a group of capacity measures of objects stored in a logical volume (the measures often have a large margin with respect to the capacity of the actual objects to be stored) and Redundant Array of Independent Disks (RAID), and one logical volume can be understood as one stripe, thereby allocating physical storage space to the logical volume.
Database (Database), which can be regarded as an electronic file cabinet in short, a place for storing electronic files, a user can add, query, update, delete, etc. to data in files. A "database" is a collection of data that is stored together in a manner that can be shared by multiple users, has as little redundancy as possible, and is independent of the application.
A Database Management System (DBMS) is a computer software System designed for managing a Database, and generally has basic functions of storage, interception, security assurance, backup, and the like. The database management system can make classification according to the database model supported by it, such as relational expression, XML (Extensible Markup Language); or classified according to the type of computer supported, e.g., server cluster, mobile phone; regardless of the type of classification used, some DBMSs can be cross-classified, e.g., supporting multiple Query languages simultaneously.
In some embodiments, the unit testing method may be implemented by a system framework as shown in fig. 1a, and a terminal equipped with the system framework and a server may form a communication system as shown in fig. 1b, so as to implement automated unit testing together. Each test is run automatically in a Continuous Integration (CI) system to implement CI automated testing.
(1) The method includes the steps that an initialized version of an app to be tested (an initial service code is integrated) is installed in advance by a mobile phone, the app to be tested integrates a hot updating technology and is used for dynamically loading an upgrade patch package, in the application, a program to be tested is obtained in a mode of loading the upgrade patch package, the app to be tested simultaneously integrates three main methods including DexClassLoader, TestExecutor and TestRequestBuilder, the DexClassLoader method is a google native api method and can be directly called, a local uninstalled application apk file can be dynamically analyzed, class and method names in apk are read, unit test cases in a test apk code can be obtained in advance and recorded through the method, and the TestExecutor and the TestRequestBuilder are google self-contained native android.
(2) And updating the remote latest service code to the local through a hot updating technology of the pre-installed app, and downloading the tested apk file to the local.
(3) And (3) specifying a path and a name of the test apk file by an addApkToScan method in the TestRequestBuilder, and adding the test case name (packet name + class name + method name) obtained in the step (1) into the builder by an addtest class method.
(4) And (3) calling a testexecute () method to execute the test case set obtained in the step (3) and starting to automatically execute the test, wherein points are buried in the test codes in advance, namely, the test results are automatically uploaded to a remote server in the case execution process, and testers can see the test progress and the unit test results in real time.
It should be particularly noted that the server related to the embodiment of the present application may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform. A terminal as referred to in embodiments of the present application may refer to a device that provides voice and/or data connectivity to a user, a handheld device having wireless connection capability, or other processing device connected to a wireless modem. For example, the terminal may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a personal digital assistant, and the like. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
Referring to fig. 2, a unit testing method provided in an embodiment of the present application is described below, where the method is performed on a terminal side, and the embodiment of the present application includes:
101. and determining the application to be tested in the non-installed state in the terminal.
The application to be tested refers to the application to be tested for the unit at this time. For example, the application to be tested is a game app to be tested. The mobile phone can be installed with an initialized version of the app to be tested in advance, namely the app integrated with the initial business code. For example, referring to fig. 2, when receiving a first message sent by a server, it may be determined that an application to be tested in an uninstalled state is not processed in a terminal.
102. And starting a preset hot update plug-in the application to be tested, and carrying out hot update on the application to be tested based on the hot update plug-in so as to obtain an update file from a server.
And the update file is a tested program associated with the application to be tested.
For example, in the embodiment of the present application, the update file may be obtained by using a hot update technology. The hot update technology refers to dynamic code distribution, that is, a user can find a hot update package only when opening an app, and only needs to download and install codes of an update part during update, and update can be completed when the user opens the app again. For example, a hot update plug-in may be integrated in the app to be tested, and the latest service code in the server is updated to the local by a hot update technology of the pre-installed app, that is, the tested apk file may be downloaded to the local.
Therefore, by integrating the hot update plug-in the app to be tested in advance, the update file (i.e., the program to be tested) can be obtained in a manner of dynamically loading the upgrade patch package, and the service logic can be upgraded without perception by the user, downloading of a new application to be tested on the terminal side and installation of the new application to be tested.
103. And acquiring a target test case from the application to be tested.
In the embodiment of the present application, because the application to be tested is updated, the test on the application to be tested may be actually equivalent to the unit test on the application to be tested. That is, the target test case is a test program for testing a program under test obtained by the thermal update method. In the embodiment of the present application, the number of target test cases for performing unit testing on a tested program may be at least one, and specifically may be presented in a test case set manner, which is not limited in the embodiment of the present application. The target test case in the embodiment of the application can be compiled based on a Junit framework, and the compiling framework adopted by the target test case is not limited.
In some embodiments, since the dynamic loader, the test request class, and the test execution class may be preset in the application to be tested, the obtaining the target test case from the application to be tested includes:
starting the dynamic loader to dynamically analyze the installation package file of the application to be tested according to a dynamic loading mode so as to acquire test case information from the installation package file, wherein the test case information comprises the name of a test case package, the name of a test class and the name of a test mode;
adding the test case information into a test request class;
determining a test path for testing the tested program according to the test request class, and determining a case name of the target test case for testing the tested program;
and acquiring the target test case according to the case name.
In some embodiments, the dynamic loading mode may be implemented by DexClassLoader. For example, the DexClassLoader is called to dynamically analyze the local uninstalled application apk file, the test class and the method name in the apk file are read, and the DexClassLoader can be used to obtain the unit test case of the apk generation file for testing in advance. DexClassLoader is a class loader (ClassLoader) that can load classes from a jar or apk file containing classes. DexClassLoader is a unique class loader for the android system. When the embodiment of the application is applied to unit testing in an android system, a DexClassLoader dynamic loading jar package can be adopted.
The dynamic analysis refers to a behavior of a dynamic loader with a certain response capability, for example, a behavior of a class dexClassLoader that encapsulates a loading thread, where the behavior of the DexClassLoader is a dynamic behavior, so that unit tests can be performed in different possible operating environments.
The test request class is a method in the android system test class, and can be realized through a TestRequestBuilder. Among them, TestRequestBuilder is a method in the test class of google self-contained native android. In some embodiments, addapktosec may be included in the TestRequestBuilder. For example, the addApkToScan specify a test path of the apk file and a case name of the test case, and add test case information (packet name + class name + method name) to the builder through addtest class.
104. And loading the target test case, and executing the target test case to perform unit test on the tested program to obtain a test report.
In some embodiments, a dynamic loader may be integrated in an application under test, and the loading the target test case includes one of:
(1) and starting a dynamic loader in the application to be tested, and loading the target test case through the dynamic loader.
(2) And starting a dynamic loader in the application to be tested, loading the target test case and the program to be tested into a target process, and loading the target test case in the target process through the dynamic loader so as to facilitate a test-type testexecutor.
Therefore, the test package and the application to be tested are loaded to the same target process through the loader to run, and the separation of the test code and the code to be tested can be realized.
The unit testing (unit testing) refers to checking and verifying the smallest testable unit in the application to be tested. For example, for checking that a small, well-defined function of the code under test is correct. A unit test is used to determine the behavior of a particular function under a particular condition (or scenario). For example, a unit in a unit test in C language refers to a function, a unit in Java refers to a class, and graphical software may refer to a window or a menu. In general, the unit is the minimum tested functional module specified by human. Unit testing is the lowest level of testing activity to be performed during software development, with the individual units of the application under test being tested isolated from the rest of the program.
In some embodiments, to implement the automated testing, a test execution class may be integrated in an application under test, and the executing the target test case to perform the unit testing on the program under test includes:
starting a test execution class in the application to be tested;
and executing the target test case through the test execution class so as to perform unit test on the tested program.
The test execution class may be testexecute. The code of Test Executor is in src/executes/Test _ Executor. cpp. The execution of the Executor mainly depends on the Mesos executorDriver as an encapsulation and communicates with the meso-slave. The implementation of MesosExecutorDriver is in src/exec. The TestExecutor comprises a build (). execute (), and the TestExecutor can start to carry out automatic unit test on the tested program by calling the TestExecutor.
105. And uploading the test report to the server.
The test report includes a test result of at least one test case on the tested program, and the test result in the test report may be real-time or a summary test result of all target test cases after the unit test on the tested program is performed, which is not limited in the embodiments of the present application.
The test report is used for indicating the test progress and the unit test result, so that a tester can know the test progress and the unit test result in real time.
In some embodiments, in order to achieve automatic uploading of a test result, a persistent integration component may be further integrated in an application to be tested, and accordingly, the uploading the test report to the server includes:
starting a continuous integrated component in the application to be tested;
acquiring a test result in the unit test process in real time through the continuous integration component;
and calling the continuous integration component to automatically upload the test result obtained in real time to the server.
The persistent integration component may include a Travis CI, a Circle CI, and other components, for example, adding code related to the Travis CI to a Travis profile to generate the Travis CI. Alternatively, code related to Circle CI may be added to the Circle profile to generate the Circle CI.
In the embodiment of the application, the application to be tested can be thermally updated by starting the preset thermal update plug-in the application to be tested, and the update file acquired from the server is the program to be tested associated with the application to be tested, so that the application to be tested does not need to be repeatedly installed, the program to be tested is acquired in an update mode, a target test case is acquired from the application to be tested, the target test case is loaded, and the target test case is executed to carry out unit test on the program to be tested, and finally a test report is obtained. Therefore, on one hand, the tested terminal can be completely separated from a test case of a computer end execution unit test or a white box test, and the problem of battery aging caused by long-time connection of the mobile phone to the computer can be effectively reduced from the hardware perspective; on the other hand, compared with the prior art, when the application to be tested is installed on the terminal (e.g., a mobile phone), the popup frames (e.g., the installation popup frame, the permission popup frame, etc.) irrelevant to the unit test may appear, and only these popup frames can be manually processed, so that the real automatic processing cannot be performed, and the test efficiency is reduced. The embodiment of the application can effectively simplify the steps of unit testing, and get rid of the trouble that the application needs to be tested repeatedly when the case is executed each time and the permission box of the application is opened each time.
Any technical features mentioned in the embodiments corresponding to fig. 1a, 1b, and 2 are also applicable to the embodiments corresponding to fig. 3 to 5 in the embodiments of the present application, and the following similarities are not repeated.
A unit test method in the embodiment of the present application is described above, and an apparatus for performing the unit test method is described below.
Referring to fig. 3, a schematic structural diagram of a unit testing apparatus 30 shown in fig. 3 is applicable to unit testing of an application. The unit testing device 30 in the embodiment of the present application can implement the steps corresponding to the unit testing method executed in the embodiment corresponding to fig. 1a, fig. 1b, and fig. 2. The functions implemented by the unit testing device 30 may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions, which may be software and/or hardware. The unit testing device 30 may include a processing module 301, a loading module 302, and a transceiver module 303, and the processing module 301, the loading module 302, and the transceiver module 303 may refer to operations performed in the embodiments corresponding to fig. 1a, fig. 1b, and fig. 2, which are not described herein again.
In some embodiments, the processing module 301 is configured to determine an application to be tested in an uninstalled state in a terminal; starting a preset hot update plug-in the application to be tested, and carrying out hot update on the application to be tested based on the hot update plug-in so as to obtain an update file from a server through the transceiver module 303, wherein the update file is a tested program associated with the application to be tested; acquiring a target test case from the application to be tested;
the loading module 302 is configured to load the target test case;
the processing module 301 is further configured to execute the target test case to perform a unit test on the program under test to obtain a test report; the test report is uploaded to the server through the transceiver module 303.
In some embodiments, the processing module 301 is specifically configured to:
starting a hot update plug-in the application to be tested;
and carrying out hot updating on the application to be tested based on the hot updating plug-in so as to obtain the updating file from the server.
In some embodiments, the application to be tested is preset with a dynamic loader and a test request class, and the processing module is specifically configured to:
starting the dynamic loader to dynamically analyze the installation package file of the application to be tested according to a dynamic loading mode so as to obtain test case information from the installation package file, wherein the test case information comprises the name of a test case package, a test class name and a test mode name;
adding the test case information into a test request class;
determining a test path for testing the tested program according to the test request class, and determining a case name of the target test case for testing the tested program;
and acquiring the target test case according to the case name.
Taking the dynamic loading mode realized by the DexClassLoader as an example, the unit test case of the apk generation file for testing can be obtained in advance by calling the DexClassLoader to dynamically analyze the apk file of the terminal which is not locally provided with the application, reading the test class and the method name in the apk file, and using the DexClassLoader. DexClassLoader is a class loader (ClassLoader) that can load classes from a jar or apk file containing classes. DexClassLoader is a unique class loader for the android system. When the embodiment of the application is applied to unit testing in an android system, a De xClassLoader can be used for dynamically loading jar packets.
The dynamic analysis refers to a behavior of a dynamic loader with a certain response capability, for example, a behavior of a class dexClassLoader that encapsulates a loading thread, where the behavior of the DexClassLoader is a dynamic behavior, so that unit tests can be performed in different possible operating environments.
The test request class is a method in the android system test class, and can be realized through a TestRequestBuilder. Among them, TestRequestBuilder is a method in the test class of google self-contained native android. In some embodiments, addapktosec may be included in the TestRequestBuilder. For example, the addApkToScan specify a test path of the apk file and a case name of the test case, and add test case information (packet name + class name + method name) to the builder through addtest class.
In some embodiments, the unit testing device 30 includes a dynamic loader, that is, when the dynamic loading manner is implemented by the dynamic loader, the loading module 302 is specifically configured to:
starting a dynamic loader in the application to be tested;
and loading the target test case through the dynamic loader.
In some embodiments, the loading module 302 is specifically configured to:
starting a dynamic loader in the application to be tested;
loading the target test case and the tested program into a target process;
and loading the target test case in the target process through the dynamic loader.
In some embodiments, the processing module 301 is specifically configured to:
starting a test execution class in the application to be tested;
and executing the target test case through the test execution class so as to perform unit test on the tested program.
In some embodiments, the test report includes at least one test result; the processing module 301 is specifically configured to:
starting a continuous integrated component in the application to be tested;
acquiring a test result in the unit test process in real time through the continuous integration component;
the continuous integration component is called by the transceiver module 303 to automatically upload the test result obtained in real time to the server.
The unit testing device 30 in the embodiment of the present application is described above from the perspective of a modular functional entity, and the servers that execute the unit testing method in the embodiment of the present application are described below from the perspective of hardware processing. It should be noted that, in the embodiment shown in fig. 3 in this application, the entity device corresponding to the transceiver module 302 may be an input/output unit, a transceiver, a radio frequency circuit, a communication module, an output interface, and the like, and the entity device corresponding to the loading module 302 and the processing module 301 may be a processor. The apparatus 30 shown in fig. 3 may have a structure as shown in fig. 4, when the apparatus 30 shown in fig. 3 has a structure as shown in fig. 4, the processor and the transceiver in fig. 4 can implement the same or similar functions of the processing module 301, the loading module 302 and the transceiver module 303 provided in the apparatus embodiment corresponding to the apparatus 30, and the memory in fig. 4 stores a computer program that the processor needs to call when executing the unit testing method.
As shown in fig. 5, for convenience of description, only the portions related to the embodiments of the present application are shown, and details of the specific technology are not disclosed, please refer to the method portion of the embodiments of the present application. The terminal may be any terminal including a mobile phone, a tablet computer, a Personal Digital Assistant (PDA, for short, the whole english is: Personal Digital Assistant), a Sales terminal (POS, for short, the whole english is: Point of Sales), a vehicle-mounted computer, etc., taking the terminal as the mobile phone as an example:
fig. 5 is a block diagram illustrating a partial structure of a mobile phone related to a terminal provided in an embodiment of the present application. Referring to fig. 5, the handset includes: radio Frequency (RF) circuit 119, memory 1120, input unit 1130, display unit 1140, sensor 1150, audio circuit 1160, wireless fidelity (Wi-Fi) module 1170, processor 1180, and power supply 1190. Those skilled in the art will appreciate that the handset configuration shown in fig. 5 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 5:
RF circuit 119 may be configured to receive and transmit signals during a message transmission or a call, and in particular, receive downlink messages from a base station and process the received downlink messages to processor 1180; in addition, the data for designing uplink is transmitted to the base station. In general, RF circuit 119 includes, but is not limited to, an antenna, at least one Amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuitry 119 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email), Short Message Service (SMS), etc.
The memory 1120 may be used to store software programs and modules, and the processor 1180 may execute various functional applications and data processing of the mobile phone by operating the software programs and modules stored in the memory 1120. The memory 1120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 1120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 1130 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone. Specifically, the input unit 1130 may include a touch panel 1131 and other input devices 1132. Touch panel 1131, also referred to as a touch screen, can collect touch operations of a user on or near the touch panel 1131 (for example, operations of the user on or near touch panel 1131 by using any suitable object or accessory such as a finger or a stylus pen), and drive corresponding connection devices according to a preset program. Alternatively, the touch panel 1131 may include two parts, namely, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 1180, and can receive and execute commands sent by the processor 1180. In addition, the touch panel 1131 can be implemented by using various types, such as resistive, capacitive, infrared, and surface acoustic wave. The input unit 1130 may include other input devices 1132 in addition to the touch panel 1131. In particular, other input devices 1132 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 1140 may be used to display information input by the user or information provided to the user and various menus of the cellular phone. The Display unit 1140 may include a Display panel 1141, and optionally, the Display panel 1141 may be configured by a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, touch panel 1131 may cover display panel 1141, and when touch operation is detected on or near touch panel 1131, the touch operation is transmitted to processor 1180 to determine the type of touch event, and then processor 1180 provides corresponding visual output on display panel 1141 according to the type of touch event. Although in fig. 5, the touch panel 1131 and the display panel 1141 are two independent components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 1131 and the display panel 1141 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 1150, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1141 according to the brightness of ambient light, and the proximity sensor may turn off the display panel 1141 and/or the backlight when the mobile phone moves to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
Audio circuitry 1160, speakers 1161, and microphone 1162 may provide an audio interface between a user and a cell phone. The audio circuit 1160 may transmit the electrical signal converted from the received audio data to the speaker 1161, and convert the electrical signal into a sound signal for output by the speaker 1161; on the other hand, the microphone 1162 converts the collected sound signals into electrical signals, which are received by the audio circuit 1160 and converted into audio data, which are then processed by the audio data output processor 1180 and transmitted to, for example, another cellular phone via the RF circuit 119, or output to the memory 1120 for further processing.
Wi-Fi belongs to short-distance wireless transmission technology, and the mobile phone can help a user to receive and send emails, browse webpages, access streaming media and the like through a Wi-Fi module 1170, and provides wireless broadband internet access for the user. Although fig. 5 shows the Wi-Fi module 1170, it is understood that it does not belong to the essential constitution of the handset, and can be omitted entirely as needed within the scope of not changing the essence of the application.
The processor 1180 is a control center of the mobile phone, and is connected to various parts of the whole mobile phone through various interfaces and lines, and executes various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 1120 and calling data stored in the memory 1120, thereby performing overall monitoring of the mobile phone. Optionally, processor 1180 may include one or more processing units; preferably, the processor 1180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated within processor 1180.
The mobile phone further includes a power supply 1180 (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the processor 1180 through a power management system, so that functions of managing charging, discharging, power consumption management and the like are implemented through the power management system.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which are not described herein.
In the embodiment of the present application, the processor 1180 included in the mobile phone further has a function of controlling the steps executed by the modules in the unit testing apparatus 30.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the apparatus and the module described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and in actual implementation, there may be other divisions, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. The procedures or functions described in accordance with the embodiments of the present application are generated in whole or in part when the computer program is loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The technical solutions provided by the embodiments of the present application are introduced in detail, and the principles and implementations of the embodiments of the present application are explained by applying specific examples in the embodiments of the present application, and the descriptions of the embodiments are only used to help understanding the method and core ideas of the embodiments of the present application; meanwhile, for a person skilled in the art, according to the idea of the embodiment of the present application, there may be a change in the specific implementation and application scope, and in summary, the content of the present specification should not be construed as a limitation to the embodiment of the present application.

Claims (10)

1. A method of unit testing, the method comprising:
determining an application to be tested in an uninstalled state in a terminal;
starting a preset hot updating plug-in the application to be tested, and carrying out hot updating on the application to be tested based on the hot updating plug-in so as to obtain an updating file from a server, wherein the updating file is a tested program associated with the application to be tested;
acquiring a target test case from the application to be tested;
loading the target test case, and executing the target test case to perform unit test on the tested program to obtain a test report;
and uploading the test report to the server.
2. The method according to claim 1, wherein the presetting of a dynamic loader and a test request class in the application to be tested, and the obtaining of the target test case from the application to be tested comprises:
starting the dynamic loader to dynamically analyze the installation package file of the application to be tested according to a dynamic loading mode so as to acquire test case information from the installation package file, wherein the test case information comprises the name of a test case package, the name of a test class and the name of a test mode;
adding the test case information into the test request class;
determining a test path for testing the tested program according to the test request class, and determining a case name of the target test case for testing the tested program;
and acquiring the target test case according to the case name.
3. The method of claim 2, wherein the loading the target test case comprises:
starting a dynamic loader in the application to be tested;
and loading the target test case through the dynamic loader.
4. The method of claim 2, wherein the loading the target test case comprises:
starting a dynamic loader in the application to be tested;
loading the target test case and the tested program into a target process;
and loading the target test case in the target process through the dynamic loader.
5. The method according to any one of claims 1-4, wherein the executing the target test case to perform unit testing on the program under test comprises:
starting a test execution class in the application to be tested;
and executing the target test case through the test execution class so as to perform unit test on the tested program.
6. The method of claim 4, wherein the test report includes at least one test result; the uploading the test report to the server includes:
starting a continuous integrated component in the application to be tested;
acquiring a test result in the unit test process in real time through the continuous integration component;
and calling the continuous integration component to automatically upload the test result obtained in real time to the server.
7. A unit testing device is characterized by comprising a processing module, a transceiver module and a loading module:
the processing module is used for determining the application to be tested in the non-installed state in the terminal; starting a preset hot updating plug-in the application to be tested, carrying out hot updating on the application to be tested based on the hot updating plug-in, and acquiring an updating file from a server through the transceiver module, wherein the updating file is a tested program associated with the application to be tested; acquiring a target test case from the application to be tested;
the loading module is used for loading the target test case;
the processing module is further used for executing the target test case to perform unit test on the tested program to obtain a test report; and uploading the test report to the server through the transceiver module.
8. The unit test apparatus according to claim 7, wherein a dynamic loader and a test request class are preset in the application under test; the processing module is specifically configured to:
starting the dynamic loader to dynamically analyze the installation package file of the application to be tested according to a dynamic loading mode so as to acquire test case information from the installation package file, wherein the test case information comprises the name of a test case package, the name of a test class and the name of a test mode;
adding the test case information into the test request class;
determining a test path for testing the tested program according to the test request class, and determining a case name of the target test case for testing the tested program;
and acquiring the target test case according to the case name.
9. A unit testing apparatus, the apparatus comprising:
at least one processor, memory, and transceiver;
wherein the memory is for storing a computer program and the processor is for calling the computer program stored in the memory to perform the method of any one of claims 1-6.
10. A computer-readable storage medium comprising instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1-6.
CN202011259954.6A 2020-11-12 2020-11-12 Unit testing method, device and storage medium Pending CN114490307A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011259954.6A CN114490307A (en) 2020-11-12 2020-11-12 Unit testing method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011259954.6A CN114490307A (en) 2020-11-12 2020-11-12 Unit testing method, device and storage medium

Publications (1)

Publication Number Publication Date
CN114490307A true CN114490307A (en) 2022-05-13

Family

ID=81491429

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011259954.6A Pending CN114490307A (en) 2020-11-12 2020-11-12 Unit testing method, device and storage medium

Country Status (1)

Country Link
CN (1) CN114490307A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115525554A (en) * 2022-09-27 2022-12-27 北京瑞莱智慧科技有限公司 Automatic test method and system of model and storage medium

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7334162B1 (en) * 2003-01-29 2008-02-19 Sun Microsystems, Inc. Dynamic distribution of test execution
US20140245070A1 (en) * 2013-02-27 2014-08-28 International Business Machines Corporation Automated execution of functional test scripts on a remote system within a unit testing framework
CN104407973A (en) * 2014-11-25 2015-03-11 珠海格力电器股份有限公司 Automatic unit test realizing method and device
CN105279063A (en) * 2014-07-25 2016-01-27 腾讯科技(深圳)有限公司 Test method and apparatus, and server
US20170147324A1 (en) * 2015-11-20 2017-05-25 Google Inc. Dynamic update of an application in compilation and deployment with cold-swapping
EP3309684A1 (en) * 2016-10-17 2018-04-18 Accenture Global Solutions Limited Dynamic loading and deployment of test files to prevent interruption of text execution
CN108205494A (en) * 2016-12-20 2018-06-26 北京神州泰岳软件股份有限公司 A kind of automated testing method and device
US10146675B1 (en) * 2016-12-29 2018-12-04 EMC IP Holding Company LLC Automated code upgrade testing utilizing a copy data manager
CN109408393A (en) * 2018-11-07 2019-03-01 深圳市腾讯网络信息技术有限公司 Application testing method, device and equipment and computer readable storage medium
CN109918098A (en) * 2017-12-12 2019-06-21 优信数享(北京)信息技术有限公司 What a kind of APP heat updated mentions survey method, apparatus and system
CN111078256A (en) * 2019-12-20 2020-04-28 广州品唯软件有限公司 Upgrading method of automatic test environment, terminal and readable storage medium
WO2020119422A1 (en) * 2018-12-15 2020-06-18 深圳壹账通智能科技有限公司 Method and apparatus for loading test data, computer device and storage medium
CN111726818A (en) * 2019-03-19 2020-09-29 深圳市广和通无线股份有限公司 Wireless chip testing method and device, computer equipment and storage medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7334162B1 (en) * 2003-01-29 2008-02-19 Sun Microsystems, Inc. Dynamic distribution of test execution
US20140245070A1 (en) * 2013-02-27 2014-08-28 International Business Machines Corporation Automated execution of functional test scripts on a remote system within a unit testing framework
CN105279063A (en) * 2014-07-25 2016-01-27 腾讯科技(深圳)有限公司 Test method and apparatus, and server
CN104407973A (en) * 2014-11-25 2015-03-11 珠海格力电器股份有限公司 Automatic unit test realizing method and device
US20170147324A1 (en) * 2015-11-20 2017-05-25 Google Inc. Dynamic update of an application in compilation and deployment with cold-swapping
EP3309684A1 (en) * 2016-10-17 2018-04-18 Accenture Global Solutions Limited Dynamic loading and deployment of test files to prevent interruption of text execution
CN108205494A (en) * 2016-12-20 2018-06-26 北京神州泰岳软件股份有限公司 A kind of automated testing method and device
US10146675B1 (en) * 2016-12-29 2018-12-04 EMC IP Holding Company LLC Automated code upgrade testing utilizing a copy data manager
CN109918098A (en) * 2017-12-12 2019-06-21 优信数享(北京)信息技术有限公司 What a kind of APP heat updated mentions survey method, apparatus and system
CN109408393A (en) * 2018-11-07 2019-03-01 深圳市腾讯网络信息技术有限公司 Application testing method, device and equipment and computer readable storage medium
WO2020119422A1 (en) * 2018-12-15 2020-06-18 深圳壹账通智能科技有限公司 Method and apparatus for loading test data, computer device and storage medium
CN111726818A (en) * 2019-03-19 2020-09-29 深圳市广和通无线股份有限公司 Wireless chip testing method and device, computer equipment and storage medium
CN111078256A (en) * 2019-12-20 2020-04-28 广州品唯软件有限公司 Upgrading method of automatic test environment, terminal and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115525554A (en) * 2022-09-27 2022-12-27 北京瑞莱智慧科技有限公司 Automatic test method and system of model and storage medium
CN115525554B (en) * 2022-09-27 2024-01-30 北京瑞莱智慧科技有限公司 Automatic test method, system and storage medium for model

Similar Documents

Publication Publication Date Title
CN108345543B (en) Data processing method, device, equipment and storage medium
CN109857403B (en) Page updating method and device, page processing method and device
CN110196795B (en) Method and related device for detecting running state of mobile terminal application
CN104516812A (en) Method and device for testing software
CN111078556B (en) Application testing method and device
CN112148579B (en) User interface testing method and device
CN111666222A (en) Test method and related device
CN105610878B (en) Directory uploading method, data publishing method, terminal and server
CN115904950A (en) Test case generation method, device, equipment and storage medium
CN108984374B (en) Method and system for testing database performance
CN115756881A (en) Data processing method, device, equipment and storage medium based on SDK
CN112749074A (en) Test case recommendation method and device
CN115269361A (en) Software development kit testing method and device and readable storage medium
CN112965832A (en) Remote Procedure Call (RPC) service calling method and related device
CN114490307A (en) Unit testing method, device and storage medium
CN116303085A (en) Test reason analysis method, device, equipment and storage medium
CN115061939B (en) Data set security test method, device and storage medium
CN112084104A (en) Abnormity testing method and device
CN108269223B (en) Webpage graph drawing method and terminal
CN110489679B (en) Browser kernel processing method and device and storage medium
US20140337975A1 (en) Method for analyzing spyware and computer system
CN112667868A (en) Data detection method and device
CN115080411A (en) Interface test case generation method and device, electronic equipment and storage medium
CN115878457A (en) Test data verification method and device, electronic equipment and storage medium
CN116881143A (en) Data object copying abnormality investigation method, device, 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