Wanted to get perspectives from others on the scope of “unit test.”
Over the past year or so, I’ve noticed an increased use of “unit test” in contexts that are broader than expected. I won’t repeat the definitions from the web here but most generally focus on what a Wiki article states as “…but it is more commonly an individual function or procedure.” Or as an article at SmartBear notes: “…the smallest piece of code that can be logically isolated in a system. In most programming languages, that is a function, a subroutine, a method or property.”
Within Integration Server, that would refer to a FLOW or Java service that is limited in scope. E.g. one could write unit tests for a good number of the services in WmPublic, such as the date, list, json, string folders and more.
The SmartBear article goes on to state:
The isolated part of the definition is important. In his book “Working Effectively with Legacy Code”, author Michael Feathers states that such tests are not unit tests when they rely on external systems: “If it talks to the database, it talks across the network, it touches the file system, it requires system configuration, or it can’t be run at the same time as any other test."
This means tests for the services in the client folder, for example, would not be “unit tests” as those each “talks across the network.”
Alternatively, an article from Martin Fowler talks about how “unit test” is not as tightly defined as some people think. In addition to noting that unit testing is about “low-level” and “small part” of a software system, he points out there are variations of what is considered a “unit.” And then also describes “social” and “solitary” which leads to the use of “doubles” or “mocks.”
I tend to fall into the camp of “if is talking to another system, such as a DB, an app via API, etc.then it is not a unit test.” But I may be too rigid there.
My concern is it seems like people are using “unit test” to refer to any and all testing done by developers or in a development environment. I think that is too broad and dilutes the meaning (and hence understanding) of unit test. Say I’m working on a user story and say “development and unit testing is complete.” What can you safely assume has been tested? “Integration testing” can have the same ambiguity.
I’m very interested in thoughts and experiences from others.