Unit tests by a QA Engineer

2019-03-15 16:02发布

As I understood from some Q&A sessions (see this and this), unit tests should be written by developers.

At my previous workplace we tried to give this task to a QA Engineer, but it didn't work. May be because it was already a middle of a project and he didn't have a chance to do a significant code coverage or may be because of another reason.

Do you think it's a bad idea to free a developer from writing unit tests in a such way?

10条回答
Ridiculous、
2楼-- · 2019-03-15 16:47

There's a subtle but important difference between the intent of unit tests and QA tests: QA testing validates functionality; unit testing validates design. That is, the outer view contrasted with the inner view of the product.

QA people are unfamiliar with the internal design of the product, which is intentional because they have to mimic the user's perspective. Developers, on the other hand, know intimately the inner workings and it is to them a mechanism to validate design would be meaningful, if at all.

Hence, it is absolutely natural that developers not the QA folks write unit tests.

查看更多
女痞
3楼-- · 2019-03-15 16:47

This depends on how you plan to implement your testing workflow.

Bad:

The developer writes his code and the other person then tries to add unit tests to test this code. The problem here is that the developer will not care to write code that is easily testable. Much time may be spent either trying to adapt the unit tests to the badly testable code, or time is wasted by refactoring the original code afterwards to be better testable.

Good:

Another person than the developer writes the unit tests and the developer writes his code afterwards, trying to get all those tests on green. This may be a bit awkward at first because some basic interfaces have to exists to implement the tests against, but the basic interfaces should be defined in the design doc, so the developer can prepare the interfaces for the test developer. The advantage is, that the test developer tries to write as many tests he can think of independent of the real implementation, while the original developer would have written tests depending on the internals of his code, not imagining other problems. Else, he would have warded against them in his implementation already.

The "good" approach worked well on two of my projects, but we used an untyped language (Smalltalk) where we only needed to agree on the class names to get the tests running. In Java you have to implement at least an interface so call functions.

查看更多
劳资没心,怎么记你
4楼-- · 2019-03-15 16:48

A Developer or a fellow developer (code reviewer) should document the Unit test cases which in a way should be based on the Code developed or the Technical Design. However, a QA test cases should be written by the functionl testers that should be based on Functional Design.

The fundamental difference here is that the UT covers logic, internal flow, performance, optimization whereas the QA covers the functional flow to mimick user experience.

查看更多
淡お忘
5楼-- · 2019-03-15 16:49

Where I work we all do unit testing but not on your own code. You still write testable code and will still focus on quality. Developers become more familiar with areas of the software they are not working on. Everybody knows the code base and can take over from other developers.

For a non developer of the software to write unit testing I agree with all the other answers. It is a bad idea.

In your question you said that you had one person doing the unit testing. Good unit testing requires a lot of effort depending on the test coverage required. It is anywhere from 50% to 100% of the level of effort of the development team. One person testing a lot of developers code will be totally overwhelmed.

查看更多
登录 后发表回答