Wednesday, June 8, 2016

Things I should have done before

Surprise, that's right. Tests.

Unit tests. Instrumentation tests. UI tests.

I'm working on it, I promise (the last couple commits should show that).

Right now, I'm using Robolectric so that I can run Android tests on the JVM (because my presenters are badly designed). The reason for this is, one, its faster than booting up the emulator. And two, my application data repository is the device's package manager. You need the Android classes to invoke the package manager (even though I end up having to fake it for tests).

By mocking the rest of the classes that would normally be injected by dagger, I'm able to write tests to handle things like the presenters, and the interactors to make sure that any new code I add (see: removing view pager for fragment) does not introduce any regressions.

Once I get a test battery which works against and validates the existing code base, I will start adding tests for new code as I write them. This way, the application will be smoothly tested while it is being developed.

I hope to include tests in PadLock, ZapTorch, and SoftGlow when they are next updated, but we will see as time permits.

After some pain in figuring out how to shadow the PackageManager, I've been able to really get testing underway for PadLock. ZapTorch will arguably be more difficult, since its feature relies on hardware in the device itself. I will have to mock up situations of both success and failure and hope for the best.

More to come.

========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?

Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com

Follow my FaceBook Page
Follow my Google+ Page
=========================