Framework Testing

This page is for developers who are working on AndHow and need to write tests for AndHow itself. If you are writing tests for an application using AndHow, see elsewhere (to be written).

Testing the main functionality of AndHow is tricky

  • AndHow ties into the Java compiler as an annotation processor so testing requires running the javac compiler and verifying compilation results

  • At runtime, the main AndHow class is an immutable singleton, however, for good testing we want to put that immutable singleton into lots of different states to ensure it works correctly - Those two things cannot both (easily) be true

AndHow unit testing best practices and requirements

For any tests that either directly or indirectly cause AndHow to be initiated, creating the AndHow immutable singleton

  • Never hold a reference to the AndHow object in a way that survives beyond a single test. The AndHow testing framework 'cheats' and actually destroys the AndHow singleton instance, allowing it to be recreated. Thus, any reference to an AndHow instance held by test code has the potential to be pointing to an old instance left from a previous test.