本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペースはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらく

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシープライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
012345678901234567890123456789012345678901234567890123456789
昨日
012345678901234567890123456789012345678901234567890123456789
累計閲覧
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Spring Boot ドキュメント
Spring Boot
Getting Started with Spring BootProject Structure and ConfigurationCore ConceptsData and StateTestingDeployment
ディスカッション

Spring Boot ガイド · 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");
    }
}
この章について質問がありますか?
前の章Data and State次の章Deployment

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件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。