CN109857635A - A kind of method and apparatus of test case class output information - Google Patents
A kind of method and apparatus of test case class output information Download PDFInfo
- Publication number
- CN109857635A CN109857635A CN201811540493.2A CN201811540493A CN109857635A CN 109857635 A CN109857635 A CN 109857635A CN 201811540493 A CN201811540493 A CN 201811540493A CN 109857635 A CN109857635 A CN 109857635A
- Authority
- CN
- China
- Prior art keywords
- test
- rank
- error
- function
- warning
- 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.)
- Withdrawn
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 113
- 238000000034 method Methods 0.000 title claims abstract description 55
- 230000006870 function Effects 0.000 description 48
- 238000003860 storage Methods 0.000 description 5
- 230000000712 assembly Effects 0.000 description 3
- 238000000429 assembly Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000013100 final test Methods 0.000 description 1
- 230000008571 general function Effects 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a kind of method and apparatus of test case class output information, it can reach and facilitate debugging and test case classification.The described method includes: calling the function that can export multiple rank log informations when creation test case class;The rank for needing to be arranged the function according to test, exports the log information of corresponding level.Using the embodiment of the present invention, achievees the purpose that export different log informations when test, to save the testing time, and improved testing efficiency.
Description
Technical field
The present invention relates to computer technology, espespecially a kind of method and apparatus of test case class output information.
Background technique
In usually automatic test course, test case write and debugging process in, it would be desirable to it is as much as possible
Information determines whether test case carries out according to our expected, and in final test process, we may only need
It checks the mistake that occurs or warning information in test, otherwise may result in that test report content is too many, and analysis gets up to compare accounts for
Use the time.
For example, when execution based on the automatic test cases that python unittest writes, in the not same order of test
Section, the output information needed is different, if it is in writing and debugging the stage, then information as detailed as possible is needed to judge to survey
The executive condition of examination, and if being in the system testing stage, only need to pay close attention to mistake or warning information, if opposite test
Information is too many in report, can occupy a large amount of time to be analyzed, and leads to the increase of testing time.
Summary of the invention
In order to solve the above-mentioned technical problems, the present invention provides kind one test case class output information method and apparatus,
Different information can be exported in test case class.
In order to reach the object of the invention, the present invention provides a kind of method of test case class output information, the methods
Include:
The function that can export multiple rank log informations is called when creating test case class;
The rank for needing to be arranged the function according to test, exports the log information of corresponding level.
In a kind of exemplary embodiment, wherein the function is logger function.
In a kind of exemplary embodiment, the multiple rank includes at least one of: INFO, WARNING, ERROR.
In a kind of exemplary embodiment, the function that multiple rank log informations can be exported, comprising:
When the rank is INFO, output journal information is INFO, WARNING, ERROR;
When the rank is WARNING, output journal information is WARNING, ERROR;
When the rank is ERROR, output journal information is ERROR.
In a kind of exemplary embodiment, the test includes debugging process and test process;
The rank for needing to be arranged the function according to test includes: to be set as when the test is debugging process
INFO or WARNING;ERROR is set as when the test is test process.
In order to reach the object of the invention, the present invention also provides a kind of device of test case class output information, the dresses
It sets including calling module and setup module, in which:
The calling module calls the function that can export multiple rank log informations when for creating test case class;
The setup module exports the log letter of corresponding level for needing to be arranged the rank of the function according to test
Breath.
In a kind of exemplary embodiment, wherein the function is logger function.
In a kind of exemplary embodiment, the multiple rank includes at least one of: INFO, WARNING, ERROR.
In a kind of exemplary embodiment, the setup module can export the function of multiple rank log informations, comprising:
When the rank is INFO, the setup module output journal information is INFO, WARNING, ERROR;
When the rank is WARNING, the setup module output journal information is WARNING, ERROR;
When the rank is ERROR, the setup module output journal information is ERROR.
In a kind of exemplary embodiment, the test includes debugging process and test process;
The setup module includes: when the test is debugging process according to the rank that test needs to be arranged the function
The setup module is set as INFO or WARNING;When the test is test process, the setup module is set as
ERROR。
Compared with prior art, multiple rank log informations can be exported by calling when the present invention includes creation test case class
Function;The rank for needing to be arranged the function according to test, exports the log information of corresponding level.Output when having reached test
The purpose of different log informations to save the testing time, and improves testing efficiency.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by specification, right
Specifically noted structure is achieved and obtained in claim and attached drawing.
Detailed description of the invention
Attached drawing is used to provide to further understand technical solution of the present invention, and constitutes part of specification, with this
The embodiment of application technical solution for explaining the present invention together, does not constitute the limitation to technical solution of the present invention.
Fig. 1 is the flow chart of the method for the test case class output information of the embodiment of the present invention one;
Fig. 2 is the structural schematic diagram of the device of the test case class output information of the embodiment of the present invention two.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with attached drawing to the present invention
Embodiment be described in detail.It should be noted that in the absence of conflict, in the embodiment and embodiment in the application
Feature can mutual any combination.
Step shown in the flowchart of the accompanying drawings can be in a computer system such as a set of computer executable instructions
It executes.Also, although logical order is shown in flow charts, and it in some cases, can be to be different from herein suitable
Sequence executes shown or described step.
Embodiment one
A kind of method of test case class output information is present embodiments provided as shown in Figure 1, this method includes S11-
S12:
The function that can export multiple rank log informations is called when S11, creation test case class;
S12, the rank for needing to be arranged the function according to test, export the log information of corresponding level.
In the embodiment of the present invention, different stage information is exported when creating use-case class, compared to conventional test, can tested
When export different log informations, to save the testing time, and improve testing efficiency.
In a kind of exemplary embodiment, wherein the function is logger function.In the TestCase class of unittest
Middle addition logger function realizes the different other display functions of journal stage.
In a kind of exemplary embodiment, the multiple rank includes at least one of: INFO, WARNING, ERROR.
In a kind of exemplary embodiment, multiple ranks further include at least one of: Debug, Info, Warn, Error
And Fatal, above-mentioned log tier levels gradually increase.The current state that Info is used to feedback system is believed to the log of end user
Breath;Warn, Error, Fatal are used to the warning of feedback system, mistake, serious error, this three should be when system be run
Detect an abnormal state of affairs.
In a kind of exemplary embodiment, the function that multiple rank log informations can be exported, comprising:
When the rank is INFO, output journal information is INFO, WARNING, ERROR;
When the rank is WARNING, output journal information is WARNING, ERROR;
When the rank is ERROR, output journal information is ERROR.
By above-mentioned setting, achieve the purpose that facilitate debugging and test.
In a kind of exemplary embodiment, the test includes debugging process and test process;
The rank for needing to be arranged the function according to test includes: to be set as when the test is debugging process
INFO or WARNING;ERROR is set as when the test is test process.
In the embodiment of the present invention, the function that can export multiple rank log informations is called when creating test case class;Root
The rank for needing to be arranged the function according to test, exports the log information of corresponding level, different logs is exported when having reached test
The purpose of information to save the testing time, and improves testing efficiency.
Embodiment two
Above-described embodiment method is specifically described in the present embodiment.The application belongs to Python unittest project
Innovation and extension, relate generally to python development language, unittest frame and succession.Succession refers to that subclass can inherit use
Non-private attribute and method in parent.It is suitable for simultaneously all based on python unittest project.Unitttest frame
The unit testing frame under python, support automatic test, shared setup and teardown code, test aggregate into collection,
Independently of report frame.Unitttest provides a tool set abundant for constructing and executing use-case.
The application realizes that different journal stages are other by adding logger function in the TestCase class of Unittest
Display function, and call the function to specify the log rank to be exported when writing use-case.
(1) logger function is write to realize the different other display functions of journal stage;
Logger function is write only to need to establish once, behind use when only need to call the function.Wherein, this example
Three ranks, respectively INFO, WARNING, ERROR can be set in the logger function write;If the rank being arranged is
INFO then shows the log information of INFO, WARNING and ERROR rank, if the rank of setting is WARNING, shows
The log information of WARNING and ERROR rank shows the log information of ERROR rank if the rank of setting is ERROR;
It is exemplified below respectively:
1) output information when log rank is INFO are as follows:
2018-10-19 13:58:01,946-ERROR is Error level
2018-10-19 13:58:01,982-INF0-th is Info level
2018-10-19 13:58:01,990-WARNING-this is warning level
2) output information when log rank is WARNING are as follows:
2018-10-19 14:01:30,225-ERROR-this is Error level
2018-10-19 14:01:30,253-WARNING-tl is warning level
3) output information when log rank is ERROR are as follows:
2018-10-19 14:02:48,589-ERROR-this is Error level
Ran 3tests in 0.012s
OK
Wherein, show that the log information program of INFO rank is as follows:
Def get_logger (level=logging.INFO, file=" log.txt "):
FORMAT=" % (asctime) s-% (levelname) s-% (message) s "
Logger=logging.getLogger (_ _ name__)
Formatter=logging.Formatter (FORMAT)
Handler=logging.FileHandler (file)
handler.setFormatter(formatter)
logger.addHandler(handler)
Logger.setLevel (level=level)
return logger
Above procedure realizes the output of different stage log information by defining a general function;Wherein, parameter point
It is not level (default level of above procedure setting is INFO), output file file (being defaulted as log.txt);Format is fixed
The justice format of log information, m- rank-log when format is;Above procedure second and third, four rows instantiated one respectively
A logger (log device), formatter (formatter), handler (processor);Before the format of fifth line given processor is
The formatter in face;6th row and the 7th row add processor and setting log rank to log device;8th is about to this log device
It returns, is called for following instanceization.
(2) the specified log rank currently to be shown when passing through setupclass when creating test case class;
By the way that the general purpose function of creation is applied in multiple test case classes of creation, each test case class according to
Need to show different information;It is exemplified below:
def setUpClass(cls):
Self.logger=self.get_logger (level=logging.WARNING)
It is WARNING that #, which specifies the log rank currently to be shown, then shows the log of WARNING and ERROR rank.
(3) automation use-case is write;
Multiple logs are arranged in the application, according to different test phases, show different log informations;Write debugging rank
Section, test phase etc..
When writing automation use-case, the different phase shown is needed according to log the rank of log is respectively set.It lifts
Under such as:
def test_logger(self):
self.logger.INFO("this is INFO level")
self.logger.WARNING("this is WARNING level")
self.logger.ERROR("this is ERROR level")
Above procedure is configured three row journal displaying information, and the log rank of the first row is INFO, and the second row is
WARNING, the third line are ERROR, and in conjunction with step (2), the rank being arranged in this example is WARNING, then finally then testing report
The relevant information of WARNING and ERROR is shown in announcement.
(4) test case executes;
The log of corresponding level is shown when executing use-case according to the log rank being arranged in setupclass, and is output to survey
In examination report.
The embodiment realizes different log ranks by adding logger function in the TestCase class of unittest
Display function;When creating test case, the TestCase class of unittest is come using logger function, and according to current
Demand needs the levels of information that shows to set, to achieve the purpose that output meets the levels of information of current demand.
The application can be realized output different stage information in automatic test, pass through the TestCase class in unittest
Middle addition logger function realizes the different other display functions of journal stage, later when creating use-case class, passes through succession
The TestCase class of unittest is come using logger function, to be set in automatic test according to testing requirement current
The levels of information needed and output, to achieve the purpose that facilitate debugging and test.
The application realizes that different journal stages are other by adding logger function in the TestCase class of unittest
Display function, and using the method inherited, the rank of different logs is specified when use-case is write, and specifying before test execution need to
The rank for the log to be shown to save the testing time, and mentions to achieve the purpose that different phase shows different logs
High testing efficiency.
Embodiment three
A kind of device of test case class output information is present embodiments provided, describes to be also suitable in above method embodiment
In this present embodiment, as shown in Fig. 2, the device includes calling module 21 and setup module 22, in which:
The calling module 21 calls the letter that can export multiple rank log informations when for creating test case class
Number;
The setup module 22 exports the log of corresponding level for needing to be arranged the rank of the function according to test
Information.
In a kind of exemplary embodiment, wherein the function is logger function.
In a kind of exemplary embodiment, the multiple rank includes at least one of: INFO, WARNING, ERROR.
In a kind of exemplary embodiment, the setup module 22 can export the function of multiple rank log informations, packet
It includes:
When the rank is INFO, the 22 output journal information of setup module is INFO, WARNING, ERROR;
When the rank is WARNING, the 22 output journal information of setup module is WARNING, ERROR;
When the rank is ERROR, the 22 output journal information of setup module is ERROR.
In a kind of exemplary embodiment, the test includes debugging process and test process;
The setup module 22 includes: when the test is debugging process according to the rank that test needs to be arranged the function
Shi Suoshu setup module 22 is set as INFO or WARNING;When the test is test process, the setup module 22 is arranged
For ERROR.
Different stage information is exported in the automatic test course realized by embodiment, is realized and is exported in different phase
The purpose of different logs, to improve testing efficiency and save the testing time.
It will appreciated by the skilled person that whole or certain steps, system, dress in method disclosed hereinabove
Functional module/unit in setting may be implemented as software, firmware, hardware and its combination appropriate.In hardware embodiment,
Division between the functional module/unit referred in the above description not necessarily corresponds to the division of physical assemblies;For example, one
Physical assemblies can have multiple functions or a function or step and can be executed by several physical assemblies cooperations.Certain groups
Part or all components may be implemented as by processor, such as the software that digital signal processor or microprocessor execute, or by
It is embodied as hardware, or is implemented as integrated circuit, such as specific integrated circuit.Such software can be distributed in computer-readable
On medium, computer-readable medium may include computer storage medium (or non-transitory medium) and communication media (or temporarily
Property medium).As known to a person of ordinary skill in the art, term computer storage medium is included in for storing information (such as
Computer readable instructions, data structure, program module or other data) any method or technique in the volatibility implemented and non-
Volatibility, removable and nonremovable medium.Computer storage medium include but is not limited to RAM, ROM, EEPROM, flash memory or its
His memory technology, CD-ROM, digital versatile disc (DVD) or other optical disc storages, magnetic holder, tape, disk storage or other
Magnetic memory apparatus or any other medium that can be used for storing desired information and can be accessed by a computer.This
Outside, known to a person of ordinary skill in the art to be, communication media generally comprises computer readable instructions, data structure, program mould
Other data in the modulated data signal of block or such as carrier wave or other transmission mechanisms etc, and may include any information
Delivery media.
Claims (10)
1. a kind of method of test case class output information, which is characterized in that the described method includes:
The function that can export multiple rank log informations is called when creating test case class;
The rank for needing to be arranged the function according to test, exports the log information of corresponding level.
2. the method according to claim 1, wherein wherein, the function is logger function.
3. the method according to claim 1, wherein the multiple rank includes at least one of: INFO,
WARNING、ERROR。
4. according to the method described in claim 3, it is characterized in that, the function that multiple rank log informations can be exported,
Include:
When the rank is INFO, output journal information is INFO, WARNING, ERROR;
When the rank is WARNING, output journal information is WARNING, ERROR;
When the rank is ERROR, output journal information is ERROR.
5. according to the method described in claim 3, it is characterized in that, the test includes debugging process and test process;
It is described according to test need to be arranged the function rank include: when it is described test be debugging process when be set as INFO or
WARNING;ERROR is set as when the test is test process.
6. a kind of device of test case class output information, which is characterized in that described device includes calling module and setup module,
Wherein:
The calling module calls the function that can export multiple rank log informations when for creating test case class;
The setup module exports the log information of corresponding level for needing to be arranged the rank of the function according to test.
7. device according to claim 6, which is characterized in that wherein, the function is logger function.
8. device according to claim 6, which is characterized in that the multiple rank includes at least one of: INFO,
WARNING、ERROR。
9. device according to claim 8, which is characterized in that the setup module can export multiple rank log informations
Function, comprising:
When the rank is INFO, the setup module output journal information is INFO, WARNING, ERROR;
When the rank is WARNING, the setup module output journal information is WARNING, ERROR;
When the rank is ERROR, the setup module output journal information is ERROR.
10. device according to claim 8, which is characterized in that the test includes debugging process and test process;
The setup module according to test need to be arranged the function rank include: when it is described test be debugging process when described in
Setup module is set as INFO or WARNING;When the test is test process, the setup module is set as ERROR.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811540493.2A CN109857635A (en) | 2018-12-17 | 2018-12-17 | A kind of method and apparatus of test case class output information |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811540493.2A CN109857635A (en) | 2018-12-17 | 2018-12-17 | A kind of method and apparatus of test case class output information |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109857635A true CN109857635A (en) | 2019-06-07 |
Family
ID=66891332
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811540493.2A Withdrawn CN109857635A (en) | 2018-12-17 | 2018-12-17 | A kind of method and apparatus of test case class output information |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109857635A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051093A (en) * | 2021-03-16 | 2021-06-29 | 长沙景嘉微电子股份有限公司 | OpenGL-driven error grading processing method and device and electronic equipment |
-
2018
- 2018-12-17 CN CN201811540493.2A patent/CN109857635A/en not_active Withdrawn
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051093A (en) * | 2021-03-16 | 2021-06-29 | 长沙景嘉微电子股份有限公司 | OpenGL-driven error grading processing method and device and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107273286B (en) | Scene automatic test platform and method for task application | |
US20140075242A1 (en) | Testing rest api applications | |
CN104881364A (en) | Automated testing method and system applied to Android system | |
CN106020811A (en) | Development method and device of algorithm model | |
CN112257008B (en) | Online custom flow operation system, method, medium and server | |
CN109522181B (en) | Performance test method, device and equipment of distributed storage system | |
CN106682036A (en) | Data exchange system and exchange method thereof | |
CN107066377B (en) | Page element obtaining method based on Android system and terminal equipment | |
CN104049974A (en) | Dynamic control assembly method and system | |
CN108572895B (en) | Stability test method for automatically checking software and hardware configuration under Linux | |
CN111949543A (en) | Testing method and device based on distributed platform, electronic equipment and storage medium | |
CN110059002A (en) | Generation method, test equipment, storage medium and the device of test data | |
CN109857635A (en) | A kind of method and apparatus of test case class output information | |
CN113918864A (en) | Website page testing method, testing system, testing device, electronic equipment and medium | |
US20210406158A1 (en) | Systems and methods for automated device testing | |
US10051116B2 (en) | Line diagnosis method and apparatus | |
CN103914377B (en) | Interface test method and device | |
CN113672509A (en) | Automatic testing method, device, testing platform and storage medium | |
WO2019193479A1 (en) | Cognitive robotic system for test data management activities and method employed thereof | |
CN114385507A (en) | Software test case generation method | |
CN109840213B (en) | Test data creating method, device, terminal and storage medium for GUI test | |
CN114124769A (en) | Base station testing method and device, electronic equipment and storage medium | |
CN109710509A (en) | Data checking, device, equipment and computer readable storage medium | |
CN112542200B (en) | Method and device for checking power-on parameters of nonvolatile flash memory, storage medium and terminal | |
CN113722214B (en) | Test method, test equipment and test system |
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 | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20190607 |