Test: Added Unit and Integration Tests for note-related features#13
Merged
Test: Added Unit and Integration Tests for note-related features#13
Conversation
Owner
Author
|
Proceeding with merge as the collaborator is temporarily unavailable. |
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.
Summary
This PR establishes a testing infrastructure for the SmartNotes backend, focusing on Note-related features.
It introduces a clear separation between unit and integration tests, leverages Testcontainers for realistic integration testing, and improves test readability with tree-structured reporting.
Overview
Test Coverage
NoteService(business logic with mocked dependencies)DocumentRepository(using in‑memory H2 database by default)NoteController(using MySQL and Redis containers via Testcontainers)Configuration
CI/CD Workflows
featurebranches that include thenotekeyworddevelopbranchDetailed Changes
Document Repository Changes
Replaced the existing
findByTitleAndUserIdmethod withfindFirstByTitleAndUserIdto fix an error caused when multiple documents with the same title were returned. This ensures that only the first matching document is mapped to a single result.Note-related Features Testing
Test Organization
unit/andintegration/directories for maintainability:helper/:DocumentDataBuilderandUserDataBuilder: generate customizable sample objects for repositories.JwtBuilder: builds JWT tokens for controller tests requiring authentication (full login flow will be tested separately).Example:
NoteServiceTest.GetNoteTestcovers scenarios such as:Test Options
unit/directory (*Test.java)integration/directory (*Test.java)@Tag("note")annotation@Tag("document")annotationCI/CD with GitHub Actions
workflows/_reusable-test.yml, which can be called in other workflows to run tests based on given inputworkflows/feature-test.yml, which is triggered by changes to source code (src/) on feature branches:scripts/detect-branch-name.shto detect the branch name (including thenotekeyword) and specify the test tag to be triggeredworkflows/_reusable-test.ymlto execute all unit testsworkflows/ci-cd-develop.yml, which is triggered when a PR is created for thedevelopbranch. It runs all unit and integration tests, and also builds and pushes images to Docker Hub (placeholder only, to be implemented later).Documentation
Instructions
Running Test Locally
Run with IntelliJ IDEA
Use the run button on individual test methods or classes.
Run with commands (Windows)
Optionally run a specific test group with tags. Use boolean expressions for tag combinations:
Upcomming Works
Test other features
All tests should be labelled with JUnit Tag using
@Tag()annotationContinue CI/CD Setup
Extra check for CI (linting and security checks, etc):
workflows/_reusable-test.yml, or create new reusable workflowOn changes to
featurebranch (feature-test.yml)scripts/detect-branch-name.sh, mapping the branch name to defined JUnit Tag.On PR to
developbranch (ci-cd-develop.yml)