Disclosure of Invention
In order to overcome the problems in the related art, the invention provides a testing method and a testing device.
According to a first aspect of embodiments of the present invention, there is provided a test method, the method comprising:
when data to be tested needs to be tested in a current operating environment by using a test case, acquiring environment configuration information of the current operating environment; different environment configuration information of different operation environments is different;
in the data to be tested, updating the attribute information of the data to be tested into the environment configuration information of the current operating environment;
initializing the data to be tested with the updated attribute information into a shared database;
and testing the data to be tested initialized into the shared database by using the test case in the current operating environment.
Wherein, in the data to be tested, updating the attribute information of the data to be tested to the environment configuration information of the current operating environment includes:
acquiring a preset data field in the data to be tested;
judging whether the preset data field stores content or not;
when the content is not stored in the preset data field, storing the environment configuration information of the current operating environment in the preset data field;
and when the content is stored in the preset data field, replacing the content stored in the preset data field with the environment configuration information of the current operating environment.
Wherein, in the data to be tested, updating the attribute information of the data to be tested to the environment configuration information of the current operating environment includes:
creating a new data field in the data to be tested;
storing environment configuration information for the current operating environment in the new data field.
Further, the method further comprises:
when the test of the data to be tested initialized into the shared database is completed by using the test case in the current operating environment and a test result is obtained, updating the attribute information of the test result into the environment configuration information of the current operating environment;
storing the test results with updated attribute information in the shared database.
Further, the method further comprises:
verifying the test results stored in the shared database and updated with the attribute information;
and after the verification is finished, deleting the data to be tested which is initialized into the shared database and has the attribute information of the environmental configuration information of the current operating environment, and deleting the test result which is stored in the shared database and has the attribute information of the environmental configuration information of the current operating environment.
According to a second aspect of embodiments of the present invention, there is provided a test apparatus, the apparatus comprising:
the system comprises an acquisition module, a test case acquisition module and a test execution module, wherein the acquisition module is used for acquiring environment configuration information of a current operation environment when data to be tested needs to be tested by using the test case in the current operation environment; different environment configuration information of different operation environments is different;
the first updating module is used for updating the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested;
the initialization module is used for initializing the data to be tested with the updated attribute information into a shared database;
and the testing module is used for testing the data to be tested initialized into the shared database by using the test case in the current operating environment.
Wherein the first update module comprises:
the acquisition unit is used for acquiring a preset data field in the data to be tested;
the judging unit is used for judging whether the preset data field stores content or not;
the first storage unit is used for storing the environment configuration information of the current operating environment in the preset data field when the content is not stored in the preset data field;
and the replacing unit is used for replacing the content stored in the preset data field with the environment configuration information of the current operating environment when the content is stored in the preset data field.
Wherein the first update module comprises:
the creating unit is used for creating a new data field in the data to be tested;
and the second storage unit is used for storing the environment configuration information of the current operating environment in the new data field.
Further, the apparatus further comprises:
the second updating module is used for updating the attribute information of the test result into the environment configuration information of the current operation environment when the test case is used for testing the data to be tested initialized into the shared database in the current operation environment and obtaining the test result;
and the storage module is used for storing the test result with the updated attribute information in the shared database.
Further, the apparatus further comprises:
the verification module is used for verifying the test result which is stored in the shared database and updated with the attribute information;
and the deleting module is used for deleting the data to be tested which is initialized into the shared database and has the attribute information of the environmental configuration information of the current operating environment, and deleting the test result which is stored in the shared database and has the attribute information of the environmental configuration information of the current operating environment.
The technical scheme provided by the embodiment of the invention can have the following beneficial effects:
in the embodiment of the invention, when the data to be tested needs to be tested by using the test case in the current operating environment, the environment configuration information of the current operating environment is obtained; the environment configuration information is different for different operating environments. And updating the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested. Initializing the data to be tested with updated attribute information into a shared database. And testing the data to be tested initialized into the shared database by using the test case in the current operating environment.
When a plurality of different operation environments exist locally, the shared database is shared by the plurality of different operation environments, and in the process of testing the data to be tested by using the test case in each operation environment, the data to be tested needs to be initialized into the shared database, and then the data to be tested initialized into the shared database can be tested. However, two identical data cannot be initialized at the same time in a shared database.
Therefore, in the prior art, when a certain data to be tested needs to be tested in a certain operating environment by using a test case, the time from the initialization of the data to be tested in the shared database in the one operating environment to the deletion of the data to be tested initialized in the shared database is provided, if the data to be tested needs to be tested in another operating environment by using the test case, because two identical data cannot be initialized in the shared database at the same time, the data to be tested cannot be initialized in the shared database in another operating environment, and the data to be tested cannot be tested in another operating environment by using the test case, so that the test fails. That is, after the data initialized into the database in the certain operating environment is deleted, the data can be initialized into the shared database in another operating environment, so that the data can be tested by using the test case in another operating environment.
That is, in the prior art, two identical data cannot be tested by using test cases in different operating environments at the same time.
In the embodiment of the invention, when a certain data to be tested needs to be tested in a certain operation environment by using the test case, the environment configuration information of the certain operation environment is obtained; different environment configuration information of different operation environments is different; in the certain data to be tested, the attribute information of the certain data to be tested is updated to the environment configuration information of the certain running environment, and then the certain data to be tested with the updated attribute information is initialized into the shared database. During the period from the initialization of the certain data to be tested with the updated attribute information into the shared database in the certain operating environment to the deletion of the certain data to be tested with the updated attribute information initialized into the shared database, if the other data to be tested needs to be tested by using the test case in the other operating environment, the environment configuration information of the other operating environment is obtained; and updating the attribute information of the other data to be tested into the environment configuration information of the other operating environment in the other data to be tested.
Whether the certain data to be tested of which the attribute information is not updated is completely the same as the other data to be tested of which the attribute information is not updated, because the environment configuration information of the certain operating environment is different from the environment configuration information of the other operating environment, the attribute information of the certain data to be tested of which the attribute information is updated is different from the attribute information of the other data to be tested of which the attribute information is updated, and therefore, the certain data to be tested of which the attribute information is updated is not completely the same as the other data to be tested of which the attribute information is updated.
Therefore, during the period from the initialization of the certain data to be tested, in which the attribute information is updated, into the shared database in the certain operating environment to the deletion of the certain data to be tested, in which the attribute information is updated, in the shared database in the initialization, the other data to be tested, in which the attribute information is updated, can also be successfully initialized into the shared database in the other operating environment, and then the other data to be tested, in which the attribute information is updated, in the shared database in the initialization can be successfully tested by using the test case in the other operating environment.
Therefore, compared with the prior art, the embodiment of the invention can simultaneously test two identical data by using the test cases in different operating environments.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
FIG. 1 is a flow chart illustrating a method of testing, as shown in FIG. 1, including the following steps, according to an exemplary embodiment.
In step S101, when the data to be tested needs to be tested in the current operating environment by using the test case, obtaining environment configuration information of the current operating environment; the environment configuration information is different for different operating environments.
In the embodiment of the present invention, a technician sets a piece of configuration information for each operating environment locally in advance, and the environment configuration information set for different operating environments is different, that is, the environment configuration information of any two operating environments is different.
The environment configuration information of the operating environment may be a name or a number of the operating environment, or may be other contents, which is not limited in the present invention, and it is only necessary to satisfy that the environment configuration information of different operating environments is different.
For example, the environment configuration information of the sit running environment is sitTnt, and the environment configuration information of the dev running environment is devTnt.
In step S102, in the data to be tested, the attribute information of the data to be tested is updated to the environment configuration information of the current operating environment.
In the embodiment of the present invention, this step may be implemented in the following two ways.
One method comprises the following steps:
11. and acquiring a preset data field in the data to be tested.
The preset data field is one of a plurality of different existing data fields in the data to be tested, for example, an owner field for storing an owner of the data to be tested, a time field for storing a generation time for generating the data to be tested, or an address field for storing a generation address for generating the data to be tested, and the like.
12. And judging whether the preset data field stores the content or not.
In the embodiment of the present invention, the preset data field in the data to be tested may or may not store the content.
For example, assuming that the preset data field is an owner field, when the data to be tested is initially generated, if the owner of the data to be tested is not obtained, the owner of the data to be tested is not stored in the owner field of the data to be tested, so that no content is stored in the owner field of the data to be tested. When the data to be tested is initially generated, if the owner of the data to be tested is obtained, the owner of the data to be tested is stored in the owner field of the data to be tested, so that the content is stored in the owner field of the data to be tested.
13. And when the content is not stored in the preset data field, storing the environment configuration information of the current operating environment in the preset data field so as to update the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested.
In the embodiment of the invention, when the content is not stored in the preset data field, the environment configuration information of the current operation environment can be stored in the preset data field, so that the attribute information of the data to be tested is updated to the environment configuration information of the current operation environment, and further the attribute information of the data to be tested is updated to the environment configuration information of the current operation environment in the data to be tested
14. When the content is stored in the preset data field, the content stored in the preset data field is replaced by the environment configuration information of the current operation environment, so that the attribute information of the data to be tested is updated to the environment configuration information of the current operation environment in the data to be tested.
In the embodiment of the invention, when the content is stored in the preset data field, the content stored in the preset storage field can be deleted, and then the environment configuration information of the current operating environment is stored in the preset data field, so that the content stored in the preset data field can be replaced by the environment configuration information of the current operating environment, and further the attribute information of the data to be tested is updated to the environment configuration information of the current operating environment in the data to be tested.
The other mode comprises the following steps:
21. a new data field is created in the data to be tested.
22. And storing the environment configuration information of the current operating environment in the new data field so as to update the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested.
In the embodiment of the present invention, the created new data field does not store any content, so that the environment configuration information of the current operating environment can be stored in the created new data field at this time, and thus, in the data to be tested, the attribute information of the data to be tested is updated to the environment configuration information of the current operating environment.
In step S103, the data to be tested, whose attribute information is updated, is initialized into the shared database.
In step S104, the data to be tested initialized into the shared database is tested by using the test case in the current running environment.
In the embodiment of the invention, when the data to be tested needs to be tested by using the test case in the current operating environment, the environment configuration information of the current operating environment is obtained; the environment configuration information is different for different operating environments. And updating the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested. Initializing the data to be tested with updated attribute information into a shared database. And testing the data to be tested initialized into the shared database by using the test case in the current operating environment.
When a plurality of different operation environments exist locally, the shared database is shared by the plurality of different operation environments, and in the process of testing the data to be tested by using the test case in each operation environment, the data to be tested needs to be initialized into the shared database, and then the data to be tested initialized into the shared database can be tested. However, two identical data cannot be initialized at the same time in a shared database.
Therefore, in the prior art, when a certain data to be tested needs to be tested in a certain operating environment by using a test case, the time from the initialization of the data to be tested in the shared database in the one operating environment to the deletion of the data to be tested initialized in the shared database is provided, if the data to be tested needs to be tested in another operating environment by using the test case, because two identical data cannot be initialized in the shared database at the same time, the data to be tested cannot be initialized in the shared database in another operating environment, and the data to be tested cannot be tested in another operating environment by using the test case, so that the test fails. That is, after the data initialized into the database in the certain operating environment is deleted, the data can be initialized into the shared database in another operating environment, so that the data can be tested by using the test case in another operating environment.
That is, in the prior art, two identical data cannot be tested by using test cases in different operating environments at the same time.
In the embodiment of the invention, when a certain data to be tested needs to be tested in a certain operation environment by using the test case, the environment configuration information of the certain operation environment is obtained; different environment configuration information of different operation environments is different; in the certain data to be tested, the attribute information of the certain data to be tested is updated to the environment configuration information of the certain running environment, and then the certain data to be tested with the updated attribute information is initialized into the shared database. During the period from the initialization of the certain data to be tested with the updated attribute information into the shared database in the certain operating environment to the deletion of the certain data to be tested with the updated attribute information initialized into the shared database, if the other data to be tested needs to be tested by using the test case in the other operating environment, the environment configuration information of the other operating environment is obtained; and updating the attribute information of the other data to be tested into the environment configuration information of the other operating environment in the other data to be tested.
Whether the certain data to be tested of which the attribute information is not updated is completely the same as the other data to be tested of which the attribute information is not updated, because the environment configuration information of the certain operating environment is different from the environment configuration information of the other operating environment, the attribute information of the certain data to be tested of which the attribute information is updated is different from the attribute information of the other data to be tested of which the attribute information is updated, and therefore, the certain data to be tested of which the attribute information is updated is not completely the same as the other data to be tested of which the attribute information is updated.
Therefore, during the period from the initialization of the certain data to be tested, in which the attribute information is updated, into the shared database in the certain operating environment to the deletion of the certain data to be tested, in which the attribute information is updated, in the shared database in the initialization, the other data to be tested, in which the attribute information is updated, can also be successfully initialized into the shared database in the other operating environment, and then the other data to be tested, in which the attribute information is updated, in the shared database in the initialization can be successfully tested by using the test case in the other operating environment.
Therefore, compared with the prior art, the embodiment of the invention can simultaneously test two identical data by using the test cases in different operating environments.
In the foregoing embodiment, after the test of the to-be-tested data initialized into the shared database by using the test case in the current operating environment is completed, a test result for testing the to-be-tested data initialized into the shared database is obtained, so that the test result can be verified.
Further, in another embodiment of the present invention, referring to fig. 2, the method further comprises:
in step S201, when the data to be tested initialized in the shared database is tested by using the test case in the current operating environment and a test result is obtained, in the test result, the attribute information of the test result is updated to the environment configuration information of the current operating environment.
Wherein, the environment configuration information of different operation environments is different.
In this step, the specific step of updating the attribute information of the test result to the environment configuration information of the current operating environment may refer to the specific process of "updating the attribute information of the data to be tested to the environment configuration information of the current operating environment in the data to be tested" in step S102, which is not described in detail herein.
In step S202, the test result with the updated attribute information is stored in the shared database.
After storing the test result with updated attribute information in the shared database, further, in another embodiment of the present invention, referring to fig. 3, the method further includes:
in step S301, the test result stored in the shared database, the attribute information of which is updated, is verified.
In step S302, after the verification is completed, the data to be tested, which is initialized into the shared database and whose attribute information is the environment configuration information of the current operating environment, is deleted, and the test result, which is stored in the shared database and whose attribute information is the environment configuration information of the current operating environment, is deleted.
In the embodiments shown in fig. 2 and fig. 3, after the test result is obtained, the test result needs to be stored in the shared database, then the test result stored in the shared database is verified, and after the verification is completed, the to-be-tested data initialized into the shared database and having the attribute information as the environment configuration information of the current operating environment is deleted, and the test result stored in the shared database and having the attribute information as the environment configuration information of the current operating environment is deleted.
When a certain data to be tested initialized in the shared database needs to be deleted in a certain operating environment, the data to be tested can be deleted according to a specific condition, for example, the data can be deleted according to attribute information of the data. If the attribute information of the data to be tested, which needs to be deleted, is AAA, when the data is deleted in the shared database according to the attribute information AAA in the operating environment, the attribute information of the data to be tested, which needs to be deleted, is AAA, so that the data to be tested is deleted from the shared database.
However, if other data to be tested has been initialized into the shared database in other operating environments at this time, the other data to be tested is not exactly the same as the data to be tested that needs to be deleted, but the attribute information of the other data and the attribute information of the data to be tested that needs to be deleted are both the attribute information AAA, when the data is deleted in the shared database according to the attribute information AAA in the operating environment, not only the data to be tested is deleted from the shared database, but also the other data to be tested that is initialized into the shared database in other operating environments is deleted in the shared database at the same time.
If the other data to be tested initialized into the shared database is not tested by using the test case in other operating environments, and the other data to be tested initialized into the shared database is deleted in the certain operating environment, the other data to be tested initialized into the shared database cannot be tested by using the test case in other operating environments, so that the other data to be tested fails to be tested.
In the embodiment of the present invention, in each of the aforementioned embodiments, before the data to be tested needs to be initialized into the shared database in one operating environment, the attribute information of the data to be tested needs to be updated to the environment configuration information of the current operating environment in the data to be tested, and then the data to be tested with the updated attribute information is initialized into the shared database. That is, in all the data to be tested initialized into the shared database, the attribute information of any two data to be tested is different.
Therefore, when a certain data to be tested initialized into the shared database needs to be deleted in a certain operating environment, only the data to be tested of which the attribute information initialized into the shared database is the environment configuration information of the certain operating environment is deleted, and other data to be tested initialized into the shared database in other operating environments cannot be deleted by mistake, so that the situation that the test fails when the other data to be tested initialized into the shared database needs to be tested by using a test case in other operating environments can be avoided.
Secondly, in the embodiment of the present invention, each time before a certain test result needs to be stored in the shared database in one operating environment, the attribute information of the certain test result needs to be updated to the environment configuration information of the current operating environment in the certain test result, and then the certain test result with the updated attribute information is stored in the shared database. That is, the attribute information of any two test results is different among all the test results stored in the shared database.
Therefore, after the test on the certain test result in the certain operating environment is completed, the certain test result stored in the shared database needs to be deleted in the certain operating environment, and other test results stored in other operating environments are also stored in the shared database in time. The method and the device avoid the situation that when the environment configuration information of a certain operating environment is used as the attribute information to delete the test result in the shared database because the certain test result is not completely the same as the other test results but the attribute information is the same, the certain test result is deleted and the other test results are deleted, so that the other test results cannot be verified in other operating environments later to cause verification failure.
FIG. 4 is a block diagram illustrating a test apparatus according to an exemplary embodiment. Referring to fig. 4, the apparatus includes:
the acquisition module 11 is configured to acquire environment configuration information of a current operation environment when data to be tested needs to be tested in the current operation environment by using a test case; different environment configuration information of different operation environments is different;
the first updating module 12 is configured to update attribute information of the data to be tested to the environment configuration information of the current operating environment in the data to be tested;
the initialization module 13 is configured to initialize the data to be tested, of which the attribute information is updated, into a shared database;
and the testing module 14 is configured to test the to-be-tested data initialized into the shared database by using the test case in the current operating environment.
Wherein the first updating module 12 comprises:
the acquisition unit is used for acquiring a preset data field in the data to be tested;
the judging unit is used for judging whether the preset data field stores content or not;
the first storage unit is used for storing the environment configuration information of the current operating environment in the preset data field when the content is not stored in the preset data field;
and the replacing unit is used for replacing the content stored in the preset data field with the environment configuration information of the current operating environment when the content is stored in the preset data field.
Wherein the first updating module 12 comprises:
the creating unit is used for creating a new data field in the data to be tested;
and the second storage unit is used for storing the environment configuration information of the current operating environment in the new data field.
Further, the apparatus further comprises:
the second updating module is used for updating the attribute information of the test result into the environment configuration information of the current operation environment when the test case is used for testing the data to be tested initialized into the shared database in the current operation environment and obtaining the test result;
and the storage module is used for storing the test result with the updated attribute information in the shared database.
Further, the apparatus further comprises:
the verification module is used for verifying the test result which is stored in the shared database and updated with the attribute information;
and the deleting module is used for deleting the data to be tested which is initialized into the shared database and has the attribute information of the environmental configuration information of the current operating environment, and deleting the test result which is stored in the shared database and has the attribute information of the environmental configuration information of the current operating environment.
In the embodiment of the invention, when the data to be tested needs to be tested by using the test case in the current operating environment, the environment configuration information of the current operating environment is obtained; the environment configuration information is different for different operating environments. And updating the attribute information of the data to be tested into the environment configuration information of the current operating environment in the data to be tested. Initializing the data to be tested with updated attribute information into a shared database. And testing the data to be tested initialized into the shared database by using the test case in the current operating environment.
When a plurality of different operation environments exist locally, the shared database is shared by the plurality of different operation environments, and in the process of testing the data to be tested by using the test case in each operation environment, the data to be tested needs to be initialized into the shared database, and then the data to be tested initialized into the shared database can be tested. However, two identical data cannot be initialized at the same time in a shared database.
Therefore, in the prior art, when a certain data to be tested needs to be tested in a certain operating environment by using a test case, the time from the initialization of the data to be tested in the shared database in the one operating environment to the deletion of the data to be tested initialized in the shared database is provided, if the data to be tested needs to be tested in another operating environment by using the test case, because two identical data cannot be initialized in the shared database at the same time, the data to be tested cannot be initialized in the shared database in another operating environment, and the data to be tested cannot be tested in another operating environment by using the test case, so that the test fails. That is, after the data initialized into the database in the certain operating environment is deleted, the data can be initialized into the shared database in another operating environment, so that the data can be tested by using the test case in another operating environment.
That is, in the prior art, two identical data cannot be tested by using test cases in different operating environments at the same time.
In the embodiment of the invention, when a certain data to be tested needs to be tested in a certain operation environment by using the test case, the environment configuration information of the certain operation environment is obtained; different environment configuration information of different operation environments is different; in the certain data to be tested, the attribute information of the certain data to be tested is updated to the environment configuration information of the certain running environment, and then the certain data to be tested with the updated attribute information is initialized into the shared database. During the period from the initialization of the certain data to be tested with the updated attribute information into the shared database in the certain operating environment to the deletion of the certain data to be tested with the updated attribute information initialized into the shared database, if the other data to be tested needs to be tested by using the test case in the other operating environment, the environment configuration information of the other operating environment is obtained; and updating the attribute information of the other data to be tested into the environment configuration information of the other operating environment in the other data to be tested.
Whether the certain data to be tested of which the attribute information is not updated is completely the same as the other data to be tested of which the attribute information is not updated, because the environment configuration information of the certain operating environment is different from the environment configuration information of the other operating environment, the attribute information of the certain data to be tested of which the attribute information is updated is different from the attribute information of the other data to be tested of which the attribute information is updated, and therefore, the certain data to be tested of which the attribute information is updated is not completely the same as the other data to be tested of which the attribute information is updated.
Therefore, during the period from the initialization of the certain data to be tested, in which the attribute information is updated, into the shared database in the certain operating environment to the deletion of the certain data to be tested, in which the attribute information is updated, in the shared database in the initialization, the other data to be tested, in which the attribute information is updated, can also be successfully initialized into the shared database in the other operating environment, and then the other data to be tested, in which the attribute information is updated, in the shared database in the initialization can be successfully tested by using the test case in the other operating environment.
Therefore, compared with the prior art, the embodiment of the invention can simultaneously test two identical data by using the test cases in different operating environments.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.