What's the proper way to test a class with private methods using JUnit?
Define private method in a class and using it in another class in a same package. Here is the source code:
Here is the example of Example of Finalize method in Java
Here is an example:
Method method = targetClass.getDeclaredMethod(methodName, argClasses); method.setAccessible(true); return method.invoke(targetObject, argObjects); And for fields: Field field = targetClass.getDeclaredField(fieldName); field.setAccessible(true); field.set(object, value);