[test-improver] Add 29 Mockito unit tests for TaskService#63
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[test-improver] Add 29 Mockito unit tests for TaskService#63github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Covers: createTask validation, updateTask, getTask, deleteTask, assignTask, transitionStatus state machine, getTaskStatistics (including bug-pin for division-by-zero Bug #3), getAllTasks, getTasksByStatus, getTasksByAssignee. All tests run in <1s with no Spring context or DB. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Test Improver — automated AI assistant focused on improving tests.
Goal & Rationale
TaskServiceis the largest and most bug-prone class in the codebase (~700 lines, multiple known bugs), yet it had zero pure unit tests. The existingTaskServiceTestuses@SpringBootTest(full context, H2 DB,DataInitializerseeding) — slow, fragile, and susceptible to ordering issues.This PR adds 29 pure Mockito unit tests (
@ExtendWith(MockitoExtension.class)) that run in under 1 second with no Spring context and no database. These tests are a prerequisite for the planned god-class refactoring tracked in Issue #16.Approach
@InjectMocks TaskService+@MockforTaskRepository,UserRepository,ProjectRepositorycreateTask,updateTask,getTask,deleteTask,assignTask,transitionStatus,getTaskStatistics,getAllTasks,getTasksByStatus,getTasksByAssigneegetTaskStatistics(Bug 🔴 [BUG] ArithmeticException: Division by zero on empty project dashboard #3)transitionStatustransitionsCoverage Impact
No baseline JaCoCo data available on main branch yet (Issue #47). These tests exercise
TaskServicemethods that were previously only covered through full-context@SpringBootTest.Bug Pin:
getTaskStatistics/ Bug #3This test documents the current broken behaviour. Do NOT modify the test to pass — fix
getTaskStatistics()in the production code (guardcompletedCount == 0), then verify the othergetTaskStatistics_withCompletedTasks_returnsCorrectCountstest still passes.Trade-offs
TaskServiceTest@SpringBootTesttests continue to provide that coverage.sendTaskNotificationis a private method that swallows all exceptions; not directly testable with Mockito.Test Status
Reproducibility
mvn test -Dtest=TaskServiceMockTest -Dmaven.repo.local=/tmp/m2 -BAdd this agentic workflows to your repo
To install this agentic workflow, run