当前位置:网站首页>Software testing - interview question sharing

Software testing - interview question sharing

2022-07-06 11:08:00 As。

1. De duplicate the following list data

L = [1, 2, 3, 11, 2, 5, 3, 2, 5, 3]
L1 = list(set(L))
print(L1)   #[1, 2, 3, 5, 11]

2. The following table data , How to make data become 123456?

L = [1, 2, 3, 4, 5, 6]

s = ''
for i in L:
    s = s + str(i)
print(s)	#123456
print(type(s))	#<class 'str'>

3. Two lists of equal length require merging into one dictionary

keys = ["A", "B", "C"]
values = ["1", "2", "3"]
print(dict(zip(keys, [int(x) for x in values])))	#{'A': 1, 'B': 2, 'C': 3}

4. Merge the two lists , And eliminate duplicate values

list_1 = ['a', 'b', 'c', '1', 'A', 'winning']
list_2 = ['a', 'python', 'string']
print(set(list_1 + list_2))

5. Xiao Ming has 100 yuan , He wants to buy a hundred books , English book 5 Yuan a book , Math book 3 Yuan a book , Chinese books 0.5 Yuan a book , How many ways does he buy ?

 Problem analysis :
100 Yuan , You can buy it alone 20 This English book ,33 This math book ,200 This Chinese book , But it can also be combined , Can pass for Loop to achieve ,i= English book ,j= Math book ,k= Chinese books 

n = 0
for i in range(21):
    for j in range(34):
        for k in range(201):
            if 5 * i + 3 * j + k * 0.5 <= 100 and i + j + k == 100:
                n += 1
print(n)	#129

6. multiplication table , Use for Circulation and while loop

# for loop 
for i in range(1, 10):
    for j in range(1, i+1):
        print("%d * %d = %d" % (j, i, (j*i)), end=" ")
    print()
while loop 
n = 1
while n <= 9:
    j = 1
    while j <= n:
        print("%d * %d = %d" % (j, n, (j*n)), end=" ")
        j += 1
    print()
    n += 1

7. Bubble sort

Is to repeatedly compare two adjacent elements , If the order is wrong, switch positions ( From big to small , Or from small to large ), Repeat , Until there are no adjacent elements to exchange , It means complete .
Value is the largest ( Minimum value ) The element of will reach the top of the element list through exchange , It's like bubbling , So this is bubble sort

"""  Bubble sort  i: Indicates the number of bubbles  j: Indicates the visited element index , In every bubble ,j You need to visit from the beginning of the list to len-i The location of  """
def bubble_sort(array):
    for i in range(1, len(array)):
        for j in range(0, len(array) - i):
            if array[j] > array[j+1]:
                array[j], array[j+1] = array[j+1], array[j]
    return array

if __name__ == '__main__':
    array = [10, 17, 50, 7, 30, 24, 27, 45, 15, 5, 36, 21]
    print(bubble_sort(array))   #[5, 7, 10, 15, 17, 21, 24, 27, 30, 36, 45, 50]

8.python How to pass dynamic parameters for a custom function in ?

Use args perhaps *kwargs

9. What is? lambda function , What are the benefits ?

lambda function : Anonymous functions , There is no function name ; The advantage is that only simple operations are done , Receive any multiple parameters and return values , There is no complex function body , It can be used as a callback function , To some applications

10. The difference between a dictionary and a list ?

The data types are different , Dictionaries get data through keys , Lists are obtained by subscript indexing ; Secondly, the algorithm structure is different , Dictionary search is faster

11. Difference between process and thread ?

The process is equivalent to the train , Thread is equivalent to carriage ; There can be multiple threads in a process , It is difficult to share data between different processes , A thread is dead , It will cause the whole process to hang up

12. Say the usual linux command

ll: View all directories and files under this path
pwd: View the current path
tail -f : Check the log
cat: Check the log
sz xxx: Download the file
cd: Switch directory path
sudo su: Switch to root jurisdiction
df: Check disk usage
top:CPU see
iostat: disk IO

13. Talk about the process of interface testing , introduce request What are they ?

First , To understand the function of this interface , Functions to be implemented ; secondly , Design use cases according to interface documents , Execute use cases , By request , request URL, Request parameters , Make a request to the interface , Check whether the request parameters and return parameters meet the expectations .
request primary coverage : Encapsulates various request methods -get,post etc. , Various request parameters are encapsulated in the form of keyword parameters -Params,data, Request header -headers, Encapsulate the response content status_code,json(),cookie management

14. How to do interface testing

According to the interface documentation , Design test cases for effectiveness and invalidity , Use jmeter To test , Determine whether the use case passes through... Through assertion ;
After the request is successful , Check the warehousing of the database ; When the request fails , Check whether the error report meets the expectation , If not as expected , Then check your request parameters , Check whether the data is normal in the database ,
Finally, check the operation log to see what is wrong , Some errors are exceptions of other dependent interfaces , Some are caused by service timeout , Some errors are reported because the database fields are not updated , Some delete interfaces , It's because of the index problem

15. How to design interface test cases

Verification of request mode , request url The check , Verification of request parameters , Verification of response information
Mainly the validity verification of request parameters , And the verification of some boundary values . It's empty , There is , non-existent , Parameter format , Verification of data

16. No interface documentation , How to do interface testing

First , Will look for development documents , In the absence of it , Will find the main information for development , Request mode ,url, Request parameters , And response parameters
web The end interface obtains the request parameters by capturing packets , Then through their understanding of the project , First make a rough analysis , Confirm the situation analyzed by yourself with the development , Is it designed like this , If it is , Then sort out the use cases according to these , And require the developer to write documents as soon as possible

17. In the process of interface testing or automated testing , How to deal with data dependency of upstream and downstream interfaces

jmeter, If it is data in the same thread , Use reference , Extract and reference data through extractor , Or use global variables to control , adopt jmeter A built-in function in setproxy and proxy To test
python, Different interfaces are encapsulated into different functions or methods , Data required return come out , And use global variables to manage

18. How to test interfaces that rely on third-party data

adopt mock, In daily tests , This is mainly developed to help solve , Some services are developed locally mock Of , Some involve big data , At present, I have written a mock plug-in unit , direct mock data , I don't know much about others

19. What are there in the process of interface testing bug?

Test the reason : The format of request parameters is incorrect, and the request parameters and environment are incorrect , Result in an error , Thought it was bug, In fact, I'm not careful Development reasons : There is no validity judgment on the enumeration value

20. If the analysis interface is abnormal

First , Request method ,url, Parameter error ; Parameter format error , Parameter enumeration value error , The dependent interface exceptions of other projects lead to ; Check your request parameters , Check whether the data is normal in the database ,
Finally, check the operation log to see what is wrong , Some errors are exceptions of other dependent interfaces , Some are caused by service timeout , Some errors are reported because the database fields are not updated , Some delete interfaces , It's because of the index problem

21. The process of performance testing

First , Planning and Design Review , Understand the performance requirements to be met ;
secondly , Understand what type of interface this is ,http still dubbo, Is it a new interface or an old interface optimization , Is it a shallow data interface or a deep level long link interface , Whether the interface involves a third-party platform , Whether the interface data needs mock, In case of interface optimization , What is the historical performance
Determine the overall schedule , Specify a schedule
secondly , Prepare for the test , Mainly environmental preparation , Data preparation , Understand the current online data volume , Prepare data according to the machine in the pressure measurement environment and online environment , And design use cases
secondly , After the interface function is stable , Carry out pressure test . In case of sufficient time , First, pressure test the previous version , In order to accurately analyze the data , Pressure test this version after optimization , Through the monitoring of services and databases , Compare throughput 、TPS、 response time 、 The error rate and other indicators analyze whether the performance has been optimized , Through whether to meet this demand
secondly , In case of problems , Debug with developers in time , Improve in time and verify again Last , After the test is completed , Write performance test report

22. Introduce how to use in this project jenkins

First , Ensure that the project code can run successfully locally
secondly , stay jenkins Create project in , Configure in the project , Configure the access path of the project , Then build , Mainly in the windows Proceed under , Then configure the command to run the use case ; Finally, jenkins To configure , After setting the global properties and the configuration of the scheduled build run, you can use

23.bug location , analysis

First web End ; If it's a page UI Show questions , This is the front end bug; secondly , If it interacts with the server , Check the environment first , Is the data correct ,
If it's a mistake , See whether the error message is thrown by the front end or the server , If no interface is requested when an error is reported , The error report is the front end ,
If the interface is requested when an error is reported , Let's see if response Returned error message , If it is , Is the exception thrown by the server , At this time, check the normality of the data
First check whether the request interface of the front end is normal , Then check whether the front-end submission parameters are normal , If there is no mistake , At this time, it is basically the problem of the server , If there is any mistake , Is the front-end problem
And then there is , Data submitted successfully , But the warehousing data is wrong , For example, an enumeration value is submitted by the front end 1, But the database stores 0, At this time, it is necessary to confirm with the front and rear ends , Confirm whether they have made their own judgments
The interface test , Here are all servers bug, But in some cases , We can easily analyze , such as , The enumeration value of a field only supports 0,1, But I don't know 2 It can also be successfully stored , This situation is that the server does not verify the validity , It has no impact on our project , But it causes dirty data downstream .

24. Test strategy and test plan , The difference between test plans

The test strategy : Focus on the need for analysis , Assess the risks , Define the test scope , Determine the test method , Develop test launch plan 、 Stop completion criteria and conditions
Test plan : Describe the characteristics of the test 、 Method 、 Environmental planning , Design and selection of test tools , And the design method of test cases
test plan : Describe the scope of testing activities to be carried out 、 Method 、 Documentation of resources and progress , It mainly includes test items , The tested characteristics and the test tasks and schedule of each stage , And risk control

test plan : Mainly management documents , Emphasize what to do , Mainly clear test objectives and scope , Roles and responsibilities for implementing the plan , As well as task schedule and resource allocation , risk assessment
Test plan : Mainly technical documents , Emphasize how to do , Mainly the test method / Policy and environmental specifications , And the design and selection of tools

25.http and https The difference between

https need SSL certificate , More secure than The default is that the port number is different ,http The general default is 80,https The general default is https
http It's the hypertext transfer protocol , The message is transmitted in clear text ;https It's safe ssl Encrypted transport protocol

26.get and post The difference between

get, Most of the request parameters are exposed in url in , comparison post Less secure , Generally, there are many query interfaces get When asked , There is no length limit , and post Limited length
get It can only be carried out url code ,post You can do a variety of get The request parameters are completely preserved in the browser history ,post Request parameters in will not be preserved

27.cookie and session The difference between

cookie It's equivalent to a bank card , Store on client session Equivalent to bank account number , Stored on the server
cookie The data is stored on the browser of the client , and session In the server
cookie The safety is lower than session, Because on the client , Others can analyze the local cookie And carry on cookie cheating
session It will be saved on the server for a certain period of time , The more visits , It will lead to worse performance

28. What is the testing framework used for Automation ?

python+request+unittest+ddt+openpyxl+pymysql+logging+HTMLTestRunner
python: primary language reqeust: Interface call , Offer different http Request method ,get,post etc.
unittest: Define a test case class , Specific methods to maintain the life cycle of test cases , Include some test scenario behaviors , The test case , Expected results , Expected results , Assertion, etc ,fixture Method
ddt: Data driven ,ddt Class decorator ,data Test method decorator
openpyxl:excel Data management ; Use openpyxl Module to do excel Data reading and writing pymysql: Database interaction , Verification of data
logging: Log processing , Unified log output format , Easy to locate the problem HTMLTestRunner: Generate html Formatted test report

29.UI In automation , What are the types of element positioning ?

Is the total 8 Kind of , All static methods
By.id;By.name;By.tagName;By.className;By.cssSelector;By.linkText;By.partialLinText;By.xpath

30. Login button is used click Method to click , What else can be used ?

You can also use submit, Prerequisite needs input The type of element is submit

31. How to verify whether the check button is selected ?

adopt isSelected Method , return true Is selected ,false There is no

32. How to deal with it alert Popup ?

First jump to alert On , Then click OK or cancel Alert
alet=driver.switchTo().alert();// Switch to alert alert.accept();// determine
alert.dismiss();// Cancel

33. Where is the test data usually placed

Specific analysis of specific problems , Different data should be placed in different places Manage global parameters : For example, account password , Mailbox configuration , It can be written in the configuration file ,(ini file )
One time data : For example, register , Every time you need something different , Then use random function Multiple sets of test data for one interface : You can use parameterization ,yaml,json,excel Conduct management
Number of repeated use : For example, the various states of the order need to generate data , You can put it in the database , Every data initialization , Users clean up All independent interface projects : Data driven ,excel management

34. How to clean up the garbage data generated by the interface

Use python Connect to database , Do the operation of adding, deleting, modifying and checking ; Use setUp Do the pre operation , Do data preparation ; Use tearDown Do post operation , Clean up the data

35. How to check whether the data returned by the interface is correct

By assertion , Judge whether the return value meets the expectation Compare the data returned by the interface to see whether the data we query from the database matches

36.python How to connect to the database

adopt pymysql package , Then connect to the database , Create a data cursor object , Conduct sql To write , To transmit data , Finally release resources

37.WebDriver Of close() and quit() Differences in methods ?

close(): Just close the currently operating window quit(): Close all open windows

38.selenium automation , encounter iframe How to deal with it ?

Use switch_to.frame Switching gold iframe After the middle , Then locate the elements and operate

39.selenium Automation kind , If the switch handle ?

Get all window handles first , And then use switch_to.window() Switch to the specified window

40. What is? PO layered

Business process is separated from page element operation ; Equivalent to a configuration at the bottom of each page class, Used to maintain page elements or operation methods , It can improve the maintainability and readability of
Base layer (BasePage): Encapsulate some basic selenium The native api operation , Open the browser , Encapsulate the method of locating elements
PO layer : Element localization 、 Get element object 、 Page operation Test case layer : Business logic , Data driven The relationship between the three :PO Layer integration foundation layer , Test case layer calls PO layer

41. What is relative concurrency ? What is absolute concurrency ?

Relatively concurrent : Refers to transactions that occur within a period of time ( give an example :jmeter in , Set thread properties ,2s Start within 10 Threads , The relative concurrency is 5, Number of threads / Starting time )
Absolutely concurrent : It refers to what happens at the same time ( give an example :jmeter in , Generally, synchronous timers are used ,Synchronizing
Timer, That is, the request is issued only when a certain assembly point is reached at the same time )

41. What is performance testing ?

It refers to the system under test , Run under a certain load , Whether the indicators of the monitoring system meet the expectations

42. The load test ? Pressure test ? Concurrent test ? Stability test ?

The load test : By not applying pressure to the system under test , Until the performance index of the system reaches saturation
Pressure test : When the test system is saturated , Apply pressure , See if there are exceptions and errors , That is, the limit test of resources
Concurrent test : Whether there is deadlock when multiple users access the same program at the same time The benchmark : Compare with the existing data
Stability test : By applying pressure to the system under test , Let the program run continuously for a period of time , Pay attention to the overall operation

43. What is included in the performance test plan ?

1. Purpose of performance test
2. The structure of the tested business
3. Research on the tested business ( Data analysis )
4. Performance monitoring indicators
5. Test scheduling and testers

44. What are the performance indicators ?

throughput : Data processed within a specified time
response time : Time from request to response
TPS: Transactions per second
QPS: Query rate per second

45. How to define transactions ?

Or do it all , Or not at all ( for instance , Bank card transfer ,A Account number to B Account transfer 500, or A-500,B+500, Either it's the same )

46.QPS and TPS The difference between , Which is more suitable ?

TPS: Transactions per second , A transaction refers to the process from sending the first request to receiving the last request response in a transaction , This is used to calculate the time used and the number of transactions completed
for instance ( Single interface ):a. Send request to server ;b. Server's own internal processing ;c. The server returns the result to the client ; If it can be done every second N These three processes ,tps Namely N
QPS: Query rate per second , Is the number of queries a server can respond to per second ( Queries executed per second in the database sql The number of times ), But it does not include additions, deletions and modifications , So it's not comprehensive enough , Not recommended for use qps Describe the overall performance of the system
difference : If it is for a query interface ( Single interface ) Pressure measurement , And this interface no longer requests other interfaces , that tps=qps, otherwise ,tps≠qps, otherwise ,tps≠qps

47. Load and cpu The relationship between utilization rate is ?

CPU utilization : It refers to the real-time occupied by the program during operation CPU percentage ,CPU Usage reflects the current cpu Busy program , The reason why it goes up and down is that it takes up cpu The process of processing time may process io Waiting state but not released into wait
CPU load : It refers to the occupation of... For a certain period of time cpu The process and waiting of time cpu The number of processes in time , Wait here cpu The process of time refers to the process waiting to be awakened , Does not include handling wait State process
cpu High utilization does not mean cpu It's a big load , There is no necessary relationship between the two , No matter what cpu Is the utilization rate high or low , It doesn't necessarily matter how many tasks are waiting in line

48. How to find concurrent number 、 Mean response time 、tps The best balance of ?

1. Do as many pressure tests as possible under different concurrent numbers , Record the response time and the maximum TPS
2. According to the data of different indicators obtained , Draw the performance curve model , response time 、 throughput 、 Resource utilization , Pay attention to their intersection

49. The difference between memory overflow and memory leak ?

Memory leak : After the program applies for memory , Unable to free requested memory space
out of memory : When a program requests memory , Not enough memory for it
Relationship : Memory leak will eventually lead to memory overflow

原网站

版权声明
本文为[As。]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060912300418.html