Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Spring Boot docs
Spring Boot
Getting Started with Spring BootProject Structure and ConfigurationCore ConceptsData and StateTestingDeployment
Discussions

Spring Boot guide · 5/6

Testing

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");
    }
}

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.
Questions about this chapter?
Previous chapterData and StateNext chapterDeployment

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.