Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpacken

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
012345678901234567890123456789012345678901234567890123456789
Gestern
012345678901234567890123456789012345678901234567890123456789
Aufrufe gesamt
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

Spring Boot-Dokumentation
Spring Boot
Getting Started with Spring BootProject Structure and ConfigurationCore ConceptsData and StateTestingDeployment
Diskussionen

Spring Boot-Anleitung · 5/6

Testing

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

Spring Boot bundles JUnit Jupiter, AssertJ, Mockito and Spring Test, and supports both slice tests, which start only part of the application, and integration tests, which start all of it. This chapter goes from the fastest kind of test to the slowest.

Test dependencies and running tests

Projects generated by Initializr include a test starter per technology (spring-boot-starter-webmvc-test, spring-boot-starter-data-jpa-test and so on). Run tests through the build tool:

./gradlew test
./mvnw test

# Run a single test class
./gradlew test --tests "com.example.demo.todo.TodoServiceTests"

Plain unit tests

With constructor injection you can create objects by hand and test them without Spring at all. These tests are the fastest, so use them for business rules.

class GreetingServiceTests {

    @Test
    void greetsInTheMorning() {
        Clock morning = Clock.fixed(Instant.parse("2025-01-01T08:00:00Z"), ZoneOffset.UTC);
        GreetingService service = new GreetingService(morning);

        assertThat(service.greet("Kim")).isEqualTo("Good morning, Kim");
    }
}

Web slice: @WebMvcTest

@WebMvcTest starts only the MVC infrastructure (controllers, JSON conversion, validation) and registers no services or repositories. Replace the beans a controller depends on with mocks via @MockitoBean. MockMvcTester lets you assert on requests and responses in AssertJ style.

@WebMvcTest(TodoController.class)
class TodoControllerTests {

    @Autowired
    MockMvcTester mvc;

    @MockitoBean
    TodoService service;

    @Test
    void returnsTodo() {
        given(service.find(1L)).willReturn(new TodoResponse(1L, "Write docs", false));

        assertThat(mvc.get().uri("/api/todos/1"))
            .hasStatusOk()
            .bodyJson().extractingPath("$.title").isEqualTo("Write docs");
    }

    @Test
    void rejectsBlankTitle() {
        assertThat(mvc.post().uri("/api/todos")
                .contentType(MediaType.APPLICATION_JSON)
                .content("{\"title\": \"\"}"))
            .hasStatus(HttpStatus.BAD_REQUEST);
    }
}

The previous generation used @MockBean; it has been replaced by Spring Framework's @MockitoBean.

Data slice: @DataJpaTest

@DataJpaTest configures only JPA-related beans and runs each test in a transaction that is rolled back afterwards. If an embedded database such as H2 is on the classpath, it is used in place of your configured one by default. To run the example below as is, add testRuntimeOnly("com.h2database:h2"), or use Testcontainers as shown later.

@DataJpaTest
class TodoRepositoryTests {

    @Autowired
    TestEntityManager entityManager;

    @Autowired
    TodoRepository repository;

    @Test
    void findsOpenTodos() {
        entityManager.persist(new Todo("open"));
        Todo done = new Todo("done");
        done.complete();
        entityManager.persist(done);

        assertThat(repository.findByDoneFalseOrderByIdAsc())
            .extracting(Todo::getTitle)
            .containsExactly("open");
    }
}
Fragen zu diesem Kapitel?
Vorheriges KapitelData and StateNächstes KapitelDeployment

Full integration tests: @SpringBootTest

@SpringBootTest starts the same context as the real application. Add @AutoConfigureMockMvc when you want MockMvc, or set webEnvironment = WebEnvironment.RANDOM_PORT to start a real server on a random port.

A real database with Testcontainers

To test against the same database you run in production, use Testcontainers. It starts the database in Docker, and @ServiceConnection wires the connection details for you, so no spring.datasource.url is needed.

@Testcontainers
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class TodoRepositoryPostgresTests {

    @Container
    @ServiceConnection
    static PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:alpine");

    @Autowired
    TodoRepository repository;

    @Test
    void savesTodo() {
        Todo saved = repository.save(new Todo("from container"));
        assertThat(saved.getId()).isNotNull();
    }
}

replace = NONE tells Spring Boot to keep the container instead of swapping in an embedded database, and your Flyway migrations run against it too. When you pick testcontainers in Initializr, it also generates TestcontainersConfiguration and TestDemoApplication, so ./gradlew bootTestRun (or ./mvnw spring-boot:test-run) runs the app locally against a container database.

Summary

  • Test business rules quickly with plain unit tests, no Spring required.
  • Slice the web layer with @WebMvcTest and @MockitoBean, and the data layer with @DataJpaTest.
  • Verify complete flows with @SpringBootTest.
  • Attach a real database easily with Testcontainers and @ServiceConnection.

0 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.