In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how Appium+Python generates html test report". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how Appium+Python generates html test report" can help you solve the problem.
Analysis:
The 1.unittest unit test framework itself comes with a textTestRunner class that can generate test reports in txt text format, but the page is not intuitive enough
two。 We can import third-party libraries, such as commonly used HTMLTestRunner classes, and generate test reports in html format
3. First download the HTMLTestRunner_PY3.py script (I use Python3.7 here), and then place it in the Lib directory under the Python3.7 path, which needs to be imported (that is, import HTMLTestRunner_PY3)
The code example is as follows:
If _ _ name__ = = "_ main__": # instantiate test suite suite = unittest.TestSuite () # load test case suite.addTest (TestCase ("test_login")) # generate test report # Select specified time format timestr = time.strftime ('% YMY% MMI% d% H% M% S') Time.localtime (time.time ()) # defines the storage path of the test report and the name of the report Report = os.path.join (PATH ('Elux peg) as as f: runner = HTMLTestRunner_PY3.HTMLTestRunner (stream=f, verbosity=2) Title='XXXX Automated Test report', description=' Executive: sister Dan') runner.run (suite) # close Test report f.close ()
Parsing:
1. Display the time in the test report name: (introducing time package) timestr=time.strftime ("% Y-%m-%d-%H_%M_%S", time.localtime (time.time ()
Time.time (): gets the current timestamp
Time.ctime (): gets the string of the current time
Time.localtime (): struct_time form of the current time
Time.strftime ("% Y-%m-%d-%H_%M_%S", time.localtime ()): gets the time in a specific format, usually using this
2.TestSuite is a container, add test cases to it with addTest ()
3.Report defines the path and file name where the report is saved
The open () function is used to open a file and create a file object so that the related methods can call it for reading and writing.
Syntax: open (name [, mode [, buffering])
Name: a string value that contains the name of the file you want to access
Mode: mode determines the mode of opening files: read-only, write-only, append, and so on. All available values are shown in the complete list below. This parameter is not mandatory and the default file access mode is read-only (r).
Buffering: if the value of buffering is set to 0, there will be no hosting. If the value of buffering is 1, the line is deposited when the file is accessed. If you set the value of buffering to an integer greater than 1, this is the buffer size of the register area. If you take a negative value, the buffer size of the register area is the system default.
What is commonly used here is open (Report,'wb'): open the file Report in binary form
4.runner defines the format of the test report, stream defines the binary file to which the report is written, title is the title of the report, description is the description of the report, runner.run () is used to run the test case, and finally close the file with f.close ()!
Verbosity represents the information complexity of the test results and has three values
0 (silent mode): you can only get the total number of test cases and the total results, such as a total of 100 failures 20 successes 80
1 (default mode): very similar to the silent pattern except that there is a "." in front of each successful use case. Each failed use case is preceded by an "F"
2 (detailed mode): the test results show all relevant information for each test case
The results of the test report are as follows:
This is the end of the introduction on "how Appium+Python generates html Test report". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 228
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.