Skip to content

ダウンロード提供のテストクラスサンプル3本のJUnit 5版を作成する - #717

Open
kumagoro1202 wants to merge 5 commits into
developfrom
junit5-docs/1-5-download-samples
Open

ダウンロード提供のテストクラスサンプル3本のJUnit 5版を作成する#717
kumagoro1202 wants to merge 5 commits into
developfrom
junit5-docs/1-5-download-samples

Conversation

@kumagoro1202

Copy link
Copy Markdown
Contributor

クラス単体テストのページからダウンロード提供しているテストクラスサンプル3本(SystemAccountEntityTest.java / UserRegistrationFormTest.java / UserComponentTest.java)を、JUnit 5の合成アノテーション+インジェクション方式へ書き換えます。ダウンロードURLは維持し、JUnit 4版はlegacy_junit4/_download配下で引き続き提供します。

誤記修正:

  • SystemAccountEntity.javaのパッケージ宣言(nablarch.sample.ss11.entity)を、ページ本文・テストクラスと整合するnablarch.sample.management.userへ修正しました。旧宣言では同梱のテストクラスとコンパイルできない状態でした。

検証:

  • UserRegistrationFormTest: nablarch-testing-junit5:2.1.0の実環境で実行し、JUnit 4版と実行結果が完全に一致することを確認(変換による挙動変化なし)
  • SystemAccountEntityTest / UserComponentTest: テスト対象クラス(Nablarch 5系サンプルアプリ資材のため6系ではそのままコンパイル不可)をスタブ化した上で、テストクラス側のAPI使用をnablarch-testing 6u3 + nablarch-testing-junit5:2.1.0に対してコンパイル検証

マージ順序について: 本PRはスタックPRであり、先行PR 1-4(junit5-docs/1-4-request-deal-test)までの内容を含みます。マージ順序は 1-1 → 1-2 → 1-3 → 1-4 → 1-5 → 1-6 → 1-7 → 1-8 を厳守してください。先行PRがマージされるまで、本PRの差分表示には先行PR分の変更が含まれます。

kumagoro1202 and others added 5 commits July 10, 2026 15:05
- 06_TestFWGuide の toctree で JUnit 5用拡張機能のページを概要の直後へ移動
- 01_Abstract の特徴「JUnit4ベース」を「JUnit 5で利用可能(推奨)+JUnit 4資産と互換」へ改訂
- 01_Abstract のテストメソッド記述方法を JUnit 5(org.junit.jupiter.api.Test)ベースへ更新
- テスティングフレームワークの入口ページに新規プロジェクト/既存プロジェクトの分岐案内を追加
- 昇格に合わせて JUnit5_Extension のページ題名を「JUnit 5での利用方法」へ変更

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 05_UnitTestGuide/legacy_junit4: JUnit 4版コード例の入口ページを新設
- 06_TestFWGuide/legacy_junit4: JUnit 4での利用方法(継承モデルの書き方・
  テスト種別と継承クラスの対応表)を新設
- 両セクションを各ガイドの toctree に追加
- 入口ページの既存プロジェクト向け案内を legacy_junit4 セクションへ誘導

既存のJUnit 4記述の本体は、各ページのJUnit 5化と合わせて順次本セクションへ
移設する(本コミットは骨格の新設のみ)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 05_UnitTestGuide/01_ClassUnitTest 配下のコード例をJUnit 5
  (@EntityTest/@DbAccessTest合成アノテーション+インジェクション方式)へ書き換え
  - Bean Validation対応Form/Entityクラス単体テスト
  - Nablarch Validation対応Form/Entityクラス単体テスト
  - Action/Componentクラス単体テスト
- 従来のJUnit 4版(継承モデル)の3ページを legacy_junit4/ 配下へ移設
  (ラベルにlegacy_junit4接頭辞を付与し、画像は既存ディレクトリを参照、
  ダウンロード資材はlegacy側へ複製して自己完結化)
- 各標準ページの冒頭にJUnit 4版への案内を追加

コード例のAPI(合成アノテーション+フィールドインジェクション+supportメソッド呼び出し)は
nablarch-testing-junit5:2.1.0 に対して動作検証済み。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 02_RequestUnitTest(ウェブ/REST/バッチ/メッセージング各方式)と
  03_DealUnitTest(バッチ/メッセージング)のコード例を、JUnit 5の
  合成アノテーション+インジェクション方式へ書き換え
  - ウェブ: @BasicHttpRequestTest(baseUri=...)(getBaseUriオーバーライドを置換)
  - REST: @RestTest/@SimpleRestTest(protectedメソッドはpublic版
    readTextResource(Class, String)の使用を案内)
  - バッチ: @BatchRequestTest、メッセージング: @MessagingRequestTest/
    @MessagingReceiveTest
- JUnit 4版のテストクラス宣言パターン集を legacy_junit4/04_requestUnitTest として新設
- 誤記修正: MessagingRequestTestSupportのFQCNを実際のパッケージ
  (nablarch.test.core.messaging)に合わせて修正(旧記載はnablarch.test.core.http)
- 誤記修正: 取引単体テスト(バッチ)のBatchRequestTestSupportのimport文の
  パッケージをnablarch.test.core.batchへ修正

コード例のAPIは nablarch-testing-junit5:2.1.0 に対して動作検証済み
(no-arg execute()のテスト名解決は2.1.0のTestEventDispatcherExtensionの
実装で確認)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- SystemAccountEntityTest.java / UserRegistrationFormTest.java /
  UserComponentTest.java を、JUnit 5の合成アノテーション
  (@EntityTest/@DbAccessTest)+インジェクション方式へ書き換え
  (ダウンロードURLは維持。JUnit 4版はlegacy_junit4/_download配下で提供継続)
- 誤記修正: SystemAccountEntity.javaのパッケージ宣言を、ページ本文・
  テストクラスと整合するnablarch.sample.management.userへ修正
  (旧宣言nablarch.sample.ss11.entityではテストクラスとコンパイル不能だった)

検証:
- UserRegistrationFormTest: nablarch-testing-junit5:2.1.0環境で実行し、
  JUnit 4版と実行結果が完全一致することを確認(挙動保存の確認)
- SystemAccountEntityTest / UserComponentTest: テスト対象クラス(Nablarch 5系
  サンプルアプリ資材)をスタブ化した上で、テストクラス側のAPI使用を
  nablarch-testing 6u3 + nablarch-testing-junit5:2.1.0に対してコンパイル検証

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant