Spring / Spring CredHub Interview questions
Which is better for testing Spring CredHub integrations, Mockito or a real CredHub server, and why?
Neither replaces the other; they answer different questions. Mockito, mocking the credentials operations interface directly, is the right tool for unit-testing a service class's own logic — what it does with the value it gets back, how it reacts to a CredHubException — and it runs in milliseconds with no external dependency.
A real CredHub server, on the other hand, is what actually validates the parts a mock can't: that your generation parameters are accepted, that permissions are granted the way you expect, that mutual TLS or OAuth2 configuration is wired correctly end to end. That belongs in a smaller set of integration tests, typically run against a CredHub instance started for the test run rather than a shared environment.
A healthy test suite leans heavily on Mockito for the bulk of service-level tests, and keeps a thin layer of real-server integration tests specifically for the configuration and wiring that mocks can't exercise.
More Related questions...