-
Notifications
You must be signed in to change notification settings - Fork 5k
[DSIP-10][Unit Tests] Improve DolphinScheduler unit tests #10573
Copy link
Copy link
Closed
Labels
DSIPbackenddiscussiondiscussiondiscussionhelp wantedExtra attention is neededExtra attention is neededimprovementmake more easy to user or prompt friendlymake more easy to user or prompt friendly
Description
Search before asking
- I had searched in the issues and found no similar feature requirement.
Description
Unit Tests of high quality could not only improve the stability of Dolphin Scheduler, but also increase the readability of Dolphin Scheduler Code.
- Currently we only have around 40% UT coverage. Although DS already has E2E tests and the community are working on the API tests, it never means we do not need high quality unit tests.
- As a DS developer, every time after submitting a PR, we will see the current UT coverage of the whole project. If the coverage is too low, developers may have concerns about the stability of the application.
- Reading unit tests is one of the best approaches for new developers to understand the code. UT cases also help reviewers to review PR more easily. Furthermore, as it is hardly possible to provide docs of every detailed feature of DS, the best way is to keep UT updated.
Use case
- We could have different standards for UT for different parts of DS. For example, we have higher bar on UT for core features but lower bar for plugins.
- We could offer a list of UT cases which need to be updated, added or refactored and label them with
good first issue. For new developers to this community, writing UT is a good way to understand the code logic and it is more intriguing than refactoring docs.
Related issues
- related: [Improvement] unit test suggestion #3700
- related: [Feature][style] Replace checkstyle plugin with spotless to automatically fix formatting errors #10963
Action Items
- Add
Spotlessplugin into DolphinScheduler to enable developers to fix style / formatting errors incrementally: [Feature][style] Replace checkstyle plugin with spotless to automatically fix formatting errors #10963 - Remove dependency on
Powermock: [Improvement][Test] Remove dependency of powermock #11405 - Upgrade
jUnitdependency from4.xto5.x: [Improvement][UT] Upgrade junit to 5.+ #10976 - Migrate all legacy cases from jUnit 4 to jUnit 5 in the whole project: [Migration][Test] jUnit4 -> jUnit5 UT cases migration #12301
- Add CI checks to prevent developer from writing UTs with
jUnit4andPowermock. - Refactor typical UTs in each module as examples.
- Add docs of instructions about how to write UT in DolphinScheduler project.
- Create some easy UT refactoring tasks and label them with
good first issue. - Refactor all UTs in each module complying to
method coverage criteriaand fix the style & formatting errors of relatedtest codeandtested code. This one will be divided into sub-tasks later.
Refactoring Guideline
- We use
method coverageas refactoring metric to decouple UT cases as much as possible. - We refactor UTs with
jUnit 5instead ofjUnit 4. - We should avoid using
Powermockin UTs and remove legacy UTs which containsPowermock, see: [Improvement][Test] Remove dependency of powermock #11405 . - Scope of each PR:
Progress
- Arranged by priority:
| Module | Sub-Module | Class | issue | status |
|---|---|---|---|---|
| dolphinscheduler-api | ||||
| dolphinscheduler-master | ||||
| dolphinscheduler-worker | ||||
| dolphinscheduler-common | ||||
| dolphinscheduler-service | ||||
| dolphinscheduler-alert | dolphinscheduler-alert-server | AlertServer | ||
| dolphinscheduler-task-plugin |
Appendix: UT coverage of each module before refactoring
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DSIPbackenddiscussiondiscussiondiscussionhelp wantedExtra attention is neededExtra attention is neededimprovementmake more easy to user or prompt friendlymake more easy to user or prompt friendly
Type
Projects
Status
Done



