-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add unit and its tests #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c2c1692
Upgrade JDK from 17 to 21 in workflow
StoynovAngel 518b8d4
Potential fix for code scanning alert no. 3: Workflow does not contai…
StoynovAngel 61dbdb0
Add testing are remove odd files
a2e3b04
Merge remote-tracking branch 'origin/StoynovAngel-patch-1' into Stoyn…
b20a167
Potential fix for code scanning alert no. 5: Workflow does not contai…
StoynovAngel c5ce48c
Add simple its
d80e7fd
Remove env profile
48e5640
Remove test summary
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Tests | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| paths: | ||
| - 'backend/**' | ||
| - '.github/workflows/test.yml' | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| paths: | ||
| - 'backend/**' | ||
| - '.github/workflows/test.yml' | ||
|
|
||
| jobs: | ||
| unit-tests: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
| cache: maven | ||
|
|
||
| - name: Run unit tests | ||
| working-directory: backend | ||
| run: mvn -B test -Dtest='!*IT,!*IntegrationTest' --fail-at-end | ||
|
|
||
| - name: Upload unit test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: unit-test-results | ||
| path: backend/target/surefire-reports/ | ||
| retention-days: 7 | ||
|
|
||
| integration-tests: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
| cache: maven | ||
|
|
||
| - name: Run integration tests | ||
| working-directory: backend | ||
| run: mvn -B test -Dtest='*IT,*IntegrationTest' -Dspring.profiles.active=test --fail-at-end | ||
|
|
||
| - name: Upload integration test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: integration-test-results | ||
| path: backend/target/surefire-reports/ | ||
| retention-days: 7 | ||
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
30 changes: 30 additions & 0 deletions
30
backend/src/test/java/com/angel/autonow/ExampleControllerIT.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.angel.autonow; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.test.context.ActiveProfiles; | ||
| import org.springframework.test.web.servlet.MockMvc; | ||
|
|
||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
| @SpringBootTest | ||
| @AutoConfigureMockMvc | ||
| @ActiveProfiles("test") | ||
| class ExampleControllerIT { | ||
|
|
||
| @Autowired | ||
| private MockMvc mockMvc; | ||
|
|
||
| @Test | ||
| @DisplayName("GET /api/test should return hello") | ||
| void shouldReturnHello() throws Exception { | ||
| mockMvc.perform(get("/api/test")) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(content().string("hello")); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
backend/src/test/java/com/angel/autonow/ExampleControllerTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.angel.autonow; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class ExampleControllerTest { | ||
|
|
||
| @Test | ||
| void exampleEndpoint() { | ||
| String result = new ExampleController().exampleEndpoint(); | ||
| assertEquals("hello", result); | ||
| } | ||
| } |
19 changes: 0 additions & 19 deletions
19
backend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.