What does unit testing mean to you?

G'day

I work with a group of offshore developers who use the term unit testing rather weakly.

Their QA document talks about writing unit tests, and then unit testing the system.

This is not consistent with my interpretation of what unit testing is.

I use unit testing as a test or a set of tests that are used to implement a single class, usually as a black box. A class test may require the inclusion of other classes in the implementation, but it is usually one class that is executed using unit test (s).

Then you have functional system testing, integration testing, acceptance tests, etc.

I want to know that is a little pedantic on my part? Or is this what you think of when referring to unit tests and unit tests?

Edit: Rob Wells. I need to clarify that approaching such testing from a black box perspective is only one aspect. When using false objects to test internal behavior, you really check in terms of a white box because you know what you want to do inside the box.

+6
unit-testing integration-testing testing
source share
13 answers

I am trying to implement unit tests to test only one method. and I am making efforts to create “layouts” of classes for dependent classes and methods used by the method I'm testing ... ... so that executing code in this method does not actually invoke code in other methods, unit test should not be "Testing" (There are other unit tests for these methods). Thus, unit test reliably indicates a failure of the method that tests unit test ...

The mock classes are designed to "mimic" the interface and behavior of the dependent classes, so the method I'm testing can call them and they will behave in a standard, well-defined way in accordance with system requirements. For this approach to work, calls to such dependent classes and their methods must be performed on a well-defined interface, so that the tester process can "embed" the Mock version of the dependent class in the test class from the actual production version .... This is similar to the general design scheme called "Injection Dependency" or "Inversion of Control" (IOC)

There are several third-party tools on the market that will help you implement this template. The one I heard about is called "Rhino-Mock" or something like that ...

Edit: Rob Wells. @Charles. Thanks for this. I forgot to use mock objects to completely replace them with classes other than those that are under testing.

A few other things that I remembered after you mentioned fraudulent objects are as follows:

  • they can be used to simulate errors returned by included classes.
  • they can be used to raise specific exceptions to test for exception handling in the test class.
  • they can be used to simulate elements where installation costs are high, for example. the big end of the SQL database.
  • they can be used to check the contents of an incoming request.

For more information, take a look at Martin Fowler's article entitled " " Mocks Are not Stubs "and the article" Pragmatic Programmers " Mock Objects "

+4
source share

Unit tests are commonly used by developers to test individual sections of code. They cover borderline cases, error cases, and normal cases. They are intended to demonstrate the validity of a limited code segment. If all your device tests pass, you have demonstrated that your isolated code segments do what they should do.

When you do integration testing, you look at end-to-end cases to check if all segments that have passed unit testing work. Functional testing verifies that the code meets the requirements specified. Acceptance testing is done by end users to ensure that they endorse the final product.

+10
source share

There is no reason why unit tests cannot span multiple classes or even submodules if the test processes only one sequential business operation. Think of “calculateWage,” the BO method that uses different strategies to calculate a person’s salary. This unit test, in my opinion.

+4
source share

I have heard about the methods in which many unit tests are performed first, and development is done around them. Someone just commented that this is a "Test Driven Development" - TDD (thanks Elie).

But if it’s an offshore operation that will probably charge you more because they spend time doing these unit tests, then I’ll be careful. Get a second opinion from someone experienced with unit tests who checks what they actually do as they say.

In my opinion, unit testing will add a little more time to any development project, but, of course, may offer some quality control. However, this is the type of quality control that I would like to use in my home project. It could be something that an offshore company throws out there to give you warm fuzziness.

+3
source share

There is a difference between the process that you use for testing and the technology that is used to support it. The various structures used for unit testing are typically very flexible and can be used to test small units of code, large blocks, and even test entire processes. This flexibility can be confusing.

My recommendation is that regardless of the particular methodology or process that you adopt, you separate the various Unit Test into separate assemblies or modules. The exact arrangement depends on your code and the organization of your company.

The cumulative effect of using the Unit Test structure is that most of the code testing is automated. Accepted correctly, developers can better evaluate code code changes without going through the complete Q & A process. As for the Q and A process itself, this makes their time more productive, since the quality of the code coming out of development should be higher.

Understand that this is not the answer to all quality questions, it is just a useful tool, like the one you use.

+3
source share

Wikipedia seems to suggest that unit testing is testing the smallest amount of code that would be a class method in case of OO programming.

Some may have a more general term for what they mean by unit tests, where some may think of some integration tests as unit tests, where a unit is a mixture of components.

+2
source share

There is a traditional view of http://en.wikipedia.org/wiki/Software_testing as part of http://en.wikipedia.org/wiki/Software_engineering . but I like the idea of ​​a flexible unit test: a test is a flexible unit test if it is fast enough so that programmers always run it.

+2
source share

A unit test is the smallest and only part of the confidence you can get on your way to doing this. This is important when iteratively creating protection against regression and specification rejection, and not on how you really integrate it into your object-oriented architecture.

+2
source share

This is almost a repeat of the question. What is "Unit"? .

"Unit" can be defined flexibly. If their document does not specify the definition of "unit", you need to clarify this.

Perhaps they think of the device as a big build of code. This is not the most desirable definition.

Although I agree that you have several levels of testing (unit, module, package, application), I also think that a lot of this can be done using unit testing tools. Leading to "what is a unit?" questions are being raised all the time.

The unit is context sensitive. For an individual developer, the unit must be a class. Sometimes it also means a module or package.

For a team, however, their division may be a package or a complete application.

+1
source share

What does it matter what we think? The problem here is your unhappiness with the conditions that they use in the document. Why don't you discuss this with them?

0
source share

Ten years ago, before the current use of “unit testing” as tests written in code, the same designation was applied to manual tests. I worked for a software company with a very formalized software development process. Before writing any code, we had to write "unit tests". In this era, unit tests were written in a text document (for example, in Word). They described the exact steps that the user must follow when using the application. For example, they described the exact input for entering a type on a page to create a new client. Or the user had to search for a specific product and see that the information displayed matches the test document. So, the test was a script, followed by a tester, where they also recorded the results. When a new incarnation of unit testing appeared, he got confused for a while trying to figure out whether they mean old, human tests or new, encoded tests.

0
source share

I lead a group of offshore teams. It seems that we have a set of unit tests ... but that means little. :) Therefore, we rely more on functionality and quality testers. The problem of inheritance with unit testing is that you have full knowledge of the functionalities and you trust the developers. In the real world, it's hard to imagine ..

0
source share

Device Testing: Testing conducted with a device or with the smallest piece of software. Designed to verify that it meets its functional specification or proposed design structure.

0
source share

All Articles