Improve backend test coverage, add CI workflow, and introduce testable design with mocking#5909
Improve backend test coverage, add CI workflow, and introduce testable design with mocking#5909TwilightVoyager777 wants to merge 38 commits intoStirling-Tools:mainfrom
Conversation
Extend RotationController tests to cover partition boundaries (0°) and negative angles, ensuring valid multiples of 90 succeed; update report with partitioning details.
Add SecretMasker tests(no side effects + false positives)
Feature B: FSM coverage tests for SecretMasker
Add white-box tests for GlobalExceptionHandler
CI: add targeted tests for GlobalExceptionHandler and SecretMasker
Add MobileScannerController validation helper and tests (mocking + te…
Remove unused GitHub Actions workflows (keep course-part4-ci.yml only)
Add LanguageService stubbing test (Member C)
|
Appreciate all the testing however you have made several changes to our GHAs which should not be done, please revert all GHA changes Thanks again for the added test cases though! Certainly something we need more of |
|
Once these have been restored will review more |
|
sure I will do that soon |
balazs-szucs
left a comment
There was a problem hiding this comment.
Hi,
thanks for the PR left some comments for you.
There was a problem hiding this comment.
So, this has caused many headaches in the past, I believe we prefer not to cache via gradle. Frooodle is working some docker caching parrallel to this I believe
There was a problem hiding this comment.
SAme comment as above
| id "org.springdoc.openapi-gradle-plugin" version "1.9.0" | ||
| id "io.swagger.swaggerhub" version "1.3.2" | ||
| id "com.diffplug.spotless" version "8.1.0" | ||
| id "com.github.jk1.dependency-license-report" version "3.0.1" | ||
| id "com.github.spotbugs" version "6.1.7" apply false |
There was a problem hiding this comment.
Non-existent version according to: https://mvnrepository.com/artifact/com.github.spotbugs/spotbugs
https://github.com/spotbugs/spotbugs/releases
| spotbugs { | ||
| ignoreFailures = true | ||
| effort = "max" | ||
| reportLevel = "low" | ||
| } | ||
|
|
||
| tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach { | ||
| reports { | ||
| xml.required.set(true) | ||
| html.required.set(true) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Can you test this and add some hints, how this supposed to work?
| // title is set both as ProblemDetail.title and property "title" | ||
| assertEquals(pd.getTitle(), pd.getProperties().get("title")); |
There was a problem hiding this comment.
Is asserting (potentially) non-RFC complaint behaviour I believe, though I'll do some reasearching.
My intuition is that the ProblemDetail.title and property "title" shouldn't be both set. It's duplication
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
|
|
||
| class GlobalExceptionHandlerTest { |
There was a problem hiding this comment.
I feel like this quite light or? We obviously didn't have testing for this before the PR, but this can be great place to make more tests.
| @@ -58,6 +62,62 @@ public void testRotatePDF() throws IOException { | |||
| assertEquals(200, response.getStatusCode().value()); | |||
| } | |||
|
|
|||
| @Test | |||
| public void testRotatePDFZeroAngle() throws IOException { | |||
There was a problem hiding this comment.
is confusing.
Better test would be to: testRotatePDF_ShouldMaintainExistingRotation_WhenAngleIsZero
There was a problem hiding this comment.
if we already here maybe bump to node 24? That is the latest, right?
Description of Changes
What was changed
This pull request improves the testing infrastructure and testability of the Stirling-PDF backend.
Key changes include:
Added multiple unit tests and white-box tests for backend components such as:
Extended existing tests to cover edge cases and boundary conditions (e.g., rotation angles and validation logic).
Implemented FSM-based testing to improve coverage for certain features.
Introduced mocking and stubbing techniques to isolate dependencies and improve test reliability.
Added helper methods and small refactors to support testable design.
Added a GitHub Actions CI workflow to automatically build the backend and run core tests.
Cleaned up CI configuration by removing unused workflows.
Minor fixes and improvements including Gradle updates and small bug fixes discovered during testing.
Why the change was made
These changes were made to improve the test coverage, reliability, and maintainability of the backend system.
The work applies several software testing practices including:
By adding automated tests and CI validation, the project can detect regressions earlier and ensure that important backend components behave correctly.
Challenges encountered
Checklist
General
Documentation
Translations (if applicable)
[scripts/counter_translation.py](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)UI Changes (if applicable)
Testing (if applicable)