Skip to content

[DSIP-10][Unit Tests] Improve DolphinScheduler unit tests #10573

@EricGao888

Description

@EricGao888

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

Action Items

Refactoring Guideline

  • We use method coverage as refactoring metric to decouple UT cases as much as possible.
  • We refactor UTs with jUnit 5 instead of jUnit 4.
  • We should avoid using Powermock in UTs and remove legacy UTs which contains Powermock, 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

image
image
image
image

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions