I have created a project which is intended to demonstrate the following using Java, Maven and JUnit5
- If the
Classexists in project. - If the class contains a
methodwith a specific name - If a method is
public,private - If a method contains parameters with specific types
- If a method returns a specific type
And there could be more additions to such a list.
This project makes use of ReflectionUtils class from Junit5 and Java's Reflection API
The codebase and tests are available at GitHub
Top comments (4)
What is the purpose of such a tests?
This is so that a learner can make progress on a certain set of tasks and verify their progress. The audience is developers learning java and creating their first project
This sounds like a bad idea. Your tests should be checking that your unit of code meets it's external facing contracts; it should not need to assess the internal private methods and fields.
That depends on the use case. This is so that a learner can make progress on a certain set of tasks and verify their progress. The audience is developers learning java and creating their first project