concept single class in category java

This is an excerpt from Manning's book Java Testing with Spock.
The most basic unit tests (called logic tests by some) are those that focus on the logic of a single Java class. To test a single class in a controlled environment and isolate it from the other classes it depends on (collaborators), Spock comes with built-in support for “faking” external object communication. This capability, known as mocking and stubbing, isn’t inside vanilla JUnit; you need external libraries—for example, Mockito (https://github.com/mockito/mockito) or jMock (http://www.jmock.org/)—to achieve this isolation of a Java class.
In this chapter, you’ll see how Spock can be used for the full testing lifecycle of an enterprise application that includes multiple layers of testing procedures running either automatically (after each code change) or on demand as part of a release. Spock is suitable for both integration tests (which cover multiple classes/modules and don’t focus on a single class) and functional tests (which cover end-to-end functionality and view the whole system as a single entity instead of individual classes). Like the previous chapter, this one briefly covers the theory behind these types of tests.
Each time you want to create a new unit test, you have to decide on its scope. An automated test can focus on a single class, multiple classes, a single module, or even the whole system. The breadth of the tested area will affect several factors of your unit test, from the time it takes to complete (the more you’re trying to test, the bigger the unit test execution) to the readability and effort it takes to write it (a unit test that needs to set up several modules needs more preparation).
At one end of the spectrum, you have “pure” unit tests that focus on a single class. These are easy to write, run quickly, and depend only on the production code. At the opposite end are functional tests (also called acceptance tests) that examine the system as a whole, emulating user behavior and even interacting with the graphical user interface (GUI). A functional test sends a request to the system and expects a response without any other knowledge of the inner workings of the system.