Skip to content

Junit5 ‐ Testing private functions

Devrath edited this page Oct 24, 2023 · 1 revision

github-header-image

Using @OpenForTesting annotation

  • We can use the annotation @OpenForTesting on the production code and mark the function public to test
  • This is not the recommended way

Testing the public functions enclosed that contain private function

  • Here we can just test the public function that contains the private one test the outcome and assume the private function works
  • This is a better way of testing the private functions in the business logic