[DISCUSS] Unit tests for JSON-serializable objects
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
I think we have been suffering from the missing JSON property for a while. https://github.com/apache/druid/issues/9177 is a good example. To avoid this happening in the future, I think we need a sort of automated testing system. The system should be able to automatically pick up all objects having a constructor annotated with `@JsonCreator` and perform the serde testing. One hard thing here is we don't know what data should be provided for testing. I think One possible approach would be:
- Adding a new requirement that the author should add a new class for the serde testing. The class name should be formatted to be easily recognized by our unit testing system such as `{$ObjectName}SerdeTest` when we add a new JSON-serializable object. Also we need to add an abstract class which requires to implement `getData()` to return data for the serde testing. The abstract class checks for all JSON-serializable objects whether there is a corresponding unit test class. If it finds the valid test class, it performs all required testing. Otherwise returns an error.
Welcome any idea.
Contributor guide
Research direction
Start by reviewing issue 9177 and the discussion here to understand the missing JSON property failure. Then inspect existing Java unit-test and @JsonCreator patterns, which this issue identifies as relevant entry points. Done would require an agreed design for discovering serializable objects, supplying test data, and reporting missing serde tests; the issue does not yet define that scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100