# EDU-002 — Restore the full Practice regression baseline - **Status:** completed as test-context repair; PostgreSQL persistence coverage moved to EDU-016 - **Type:** test-enablement vertical slice - **Phase:** 0 / Phase 2 prerequisite - **Blockers:** EDU-001 ## Outcome The complete Practice test set starts reliably and distinguishes test-context failures from real behavior regressions across create, answer, restore, submit, report, wrong-question, and favorite flows. ## Why this is next The direct EDU-001 tests pass, but broader Practice tests currently fail during Spring test-context creation because test configurations that import `PracticeSessionServiceImpl` do not consistently provide its current `ScoringService` dependency. Some tests also use name-based `@Resource` injection against Mapper proxies, producing type mismatches. Continuing core-loop work without this feedback loop would hide regressions. ## Existing code and data - No legacy capability is being newly migrated. - No database object changes are required. - Existing Education test SQL and Mapper test infrastructure are reused. ## Scope 1. Inventory every test that imports, instantiates, or indirectly creates `PracticeSessionServiceImpl`. 2. For each test context, choose one explicit dependency strategy: - import the real `ScoringServiceImpl` when scoring behavior is under test; or - provide `@MockitoBean ScoringService` when the test is outside the scoring seam. 3. Replace ambiguous name-based Mapper injection only where it currently prevents the target tests from starting. 4. Run the complete focused Practice regression set. 5. Classify remaining failures as: - test assembly defect; - existing product defect; - expected contract change from EDU-001; - unrelated dirty-worktree issue. 6. Fix only test-assembly defects in this ticket. Create separate tickets for product defects. ## Reuse boundaries - Reuse `BaseDbUnitTest`, existing Education test SQL, Spring `@Import`, and `@MockitoBean`. - Do not create a parallel test framework. - Do not modify System, Member, database schema, or production state machines. - Do not weaken assertions merely to make tests green. ## Target test set ```text PracticeSessionServiceImplTest PracticeAnswerServiceImplTest PracticeSubmitServiceImplTest PracticeSubmitProjectionIntegrationTest PracticeSessionControllerHttpTest PracticeAnswerControllerHttpTest PracticeSessionControllerSubmitHttpTest WrongQuestionServiceImplTest FavoriteServiceImplTest ``` ## Acceptance criteria - [ ] Every target class starts its Spring/JUnit context. - [ ] No target class fails because `ScoringService` is missing. - [ ] No target class fails from avoidable Mapper bean-name/type injection ambiguity. - [ ] EDU-001 safe-content assertions remain green. - [ ] Any actual behavior failure is documented with reproducible command and assigned a separate ticket. - [ ] No production behavior or database schema is changed unless a failing regression proves it is necessary and the ticket is explicitly amended. ## Test command ```bash mvn -pl yudao-module-education \ -Dtest='PracticeSessionServiceImplTest,PracticeAnswerServiceImplTest,PracticeSubmitServiceImplTest,PracticeSubmitProjectionIntegrationTest,PracticeSessionControllerHttpTest,PracticeAnswerControllerHttpTest,PracticeSessionControllerSubmitHttpTest,WrongQuestionServiceImplTest,FavoriteServiceImplTest' \ -Dsurefire.failIfNoSpecifiedTests=false \ test ``` Then: ```bash git diff --check mvn -pl yudao-server -am -DskipTests clean compile ``` ## Risk and rollback - **Risk:** Low production risk; medium risk of exposing pre-existing behavior defects. - **Rollback:** Revert only this ticket's test assembly changes. There is no database rollback. ## Completion result Test-context assembly was repaired: - `ScoringService` is now explicitly mocked in Practice contexts that are not testing scoring itself. - `PracticeQuestionMapper` fields use type-based injection where name-based `@Resource` resolved the wrong MyBatis proxy. - Controller tests and `PracticeSessionServiceImplTest` start and pass. The expanded regression run then exposed a separate infrastructure limitation rather than a remaining Spring context defect: H2 cannot execute the production PostgreSQL `ON CONFLICT` statements, and the unified `education_idempotency` test table was missing. A temporary H2 table definition was added so table absence no longer masks the dialect issue, but PostgreSQL conflict semantics cannot be made truthful on H2. The required follow-up is [`EDU-016`](EDU-016-postgresql-persistence-tests.md). ## Verification result - Controller Practice tests: 39 passed. - `PracticeSessionServiceImplTest`: 24 passed before PostgreSQL-dialect persistence paths were included. - Full targeted suite starts after dependency/injection repair, then fails on confirmed H2/PostgreSQL dialect mismatch and downstream assertions. - No production behavior was changed by EDU-002.