Annotation Type TestConfiguration


@Documented @Retention(RUNTIME) @Target(TYPE) public @interface TestConfiguration

A class whose @Bean methods add beans for a BackendTest, and only for it.

A static nested class of the test is added to that test; a top-level one is added by listing it in BackendTest.classes(). A test bean is an ordinary singleton: it is injected, it receives its own injections, and it may be marked @Primary to win over the application's bean of the same type -- which is how a test swaps an implementation without a mocking library:

@TestConfiguration
static class Fakes {
    @Bean @Primary
    Mailer mailer() {
        return new RecordingMailer();
    }
}

Test beans may not be request-, session-scoped or lazy, and may not carry @Transactional, @Async or the other woven annotations.