Unit testing involves testing individual units or modules of code to determine if they work as intended. It is important because it finds problems early, facilitates change, simplifies integration, acts as documentation, and saves time. Unit tests work by being independent, automatic, fast, and isolated from external systems. Isolation is achieved through test doubles like dummies, stubs, mocks, and fakes that stand in for real objects to simplify testing.