Software testing interview questions: Tell me about your understanding of TDD test-driven development?

Many companies will ask to varying degrees "Have you ever understood TDD ? " Using this development process, the interviewer will also use your description of this relatively "unfamiliar" concept to understand your familiarity with some testing-related concepts and insights into testing ideas.

What is TDD (Test Driven Development)?

The introduction of test-driven development in Encyclopedia is as follows, test-driven development, the English full name is Test-Driven Development, referred to as TDD, it is a new development method different from the traditional software development process. It requires to write the test code before writing the code of a certain function, and then only write the function code that makes the test pass, and promote the whole development through the test. This helps to write clean, usable and high-quality code and speeds up the development process.

Test-driven development is not a method that has only been developed in recent years. It first began to practice this idea in the extreme programming methodology. There are many "extreme programming", "continuous integration", " There are different angles of introduction in the book "Test Driven Development".

To put it simply, test-driven development is an agile development practice for some small function points or even as small as a method. The traditional development mode is that developers start writing unit test scripts after writing business codes to verify the business function codes in the previous step, while the central idea of ​​test-driven development is to write test codes first according to requirements documents (that is, write unit tests first Script), and think about how to verify these business functions to be realized. After writing enough unit test scripts, continue to write business function codes. After passing the test, continue to iterate the above process until all the business is written. Required function modules.

unit test

A concept derived from the above - unit testing, here is a brief explanation. A unit test is generally an independent test written by a developer to verify each code unit developed by the developer when writing the business function code. After the unit test is completed, the developer will issue a unit test report and a unit test coverage report, and the tester needs to use the above reports as the basis for designing functional test cases .

The process of test-driven development

The core process nodes can be clearly seen from the following test-driven development cycle diagram. The mantra of test-driven development is don't run/run/refactor

The difference between test-driven development and traditional development

The unit test script written in the traditional development mode is actually to verify the function, and it is still a form of testing. And test-driven development is no longer a simple testing behavior, to be precise, it is a design behavior. Test-driven development is similar to a design specification written for the usage of a piece of code, which can be seen from the cohesion, testability, reusability, defect density, and simplicity of the interface of the written code. In test-driven development, the analysis of requirements and the understanding of user business functions are progressive, and can be gradually refined to the code level, and this process also improves the coverage of the test. Fundamentally solve some late-stage defect repair work caused by business logic design errors.

Pros and Cons of Test Driven Development

It can also be seen from the above TDD cycle diagram that the biggest advantage of test-driven development is refactoring, continuous iteration, continuous refactoring of existing code, continuous optimization of the internal structure of the code, and finally the improvement of the overall code . In this way, some design redundancy, code redundancy, interface complexity, etc. are continuously reduced.

In addition, for some early-stage requirements that are not clear, or even require very little information, and there will be a large number of business function changes later, the traditional development model needs to work overtime to catch up with development, testing, and defect repair. Said, the most important product quality can not be guaranteed. Of course, this mode is also the most suitable for adopting the prototype method and agile development mode. After all, embracing change is the purpose of agile. And test-driven development is also the basis of the agile development model, so that whether it is an urgent demand from a customer or a technical reform of the project team, it can be realized by refactoring the design and adding test scripts.

Application areas of test-driven development

The above analysis has many advantages of test-driven development, but it has not been widely used at present. First, this is a change in technology or management methods that needs to be gradually known to the public; second, it requires sufficient professional skills and expertise. High-quality talents to ensure the smooth and professional process of the whole process; Third, a certain amount of investment is required in the early stage, and the output it produces is enough to solve the problems of quality, efficiency, and cost encountered in most enterprises at present, so the choice is one step, and it can really Strictly enforced rarely.

end

In short, if it is during the interview process, you can explain your understanding of test-driven development step by step through the above aspects. If you happen to have work experience in an agile team, you can add bricks and tiles and add your own personal experience. It will definitely give the interviewer a good impression of clear thinking and rich testing experience.

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey, and I hope it can help you! Partners can click the small card below to receive   

Guess you like

Origin blog.csdn.net/kk_lzvvkpj/article/details/132025669