Abstract

The project TestExtensions provides access to non public fields and methods as help for writing tests. Developers can it use in testtools like JUnit and TestNG.

Accessing non public members lead to a SecurityException. But there is a way to manipulate the SecurityManager. The SecurityManager must allow this kind of manipulation. The standard SecurityManager of the jdk does it. So the TestExtensions manipulate the SecurityManager before accessing a non public field, method or constructor and reset the SecurityManager after the access. This is transparent for the test developer.

You can find an overview here. A short tutorial explain, how to write tests with this extensions.

Project State

At the moment is a first release available (0.1.0). This release contains all needed classes. You can create a new Instance from non public outer and inner classes, access fields and methods. There is one exception (TestExtensionException). The exception doesn't contain a suggestive message.

Some ideas for future releases:

  • A next release would contains more usefull methods, like a assertEquals method in the field.
  • It should also test the SecurityManager, if it allows the required manipulations.
  • The field and method get some assert - functions.
  • The TestExtensionsException will contain more meaningfull messages.