I’m using robotium for testing and I’m running into a bunch of timing issues that are making it difficult for me to know when an activity (or view) is done loading. As a result the tests I’m writing are not very robust.
I’m looking for a way to instrument my application under test with events that can be pushed to the test framework. If my application under test could “tell” my tests when an expect event occurs, this would be very useful. I’ve used Event Tracing for Windows for windows\windows phone in the past to great effect.
The poor mans way of doing this that I’m looking at is to have my test application read the logcat in realtime and notify the test when an expected event occurs.
Does anyone have any other ideas?
To solve this I’m relying on the OS logcat. I instrument portions of the code being tested with trace messages and wait for them to occur in the test code. Its perhaps not the most performant way of doing things, but it suits my needs. I first tried to make an asynctask that read from the logcat, but ran into timing issues. I finally implemented something like this:
EventManager code (That I wrapped in a singleton called EmSingleton):
You’ll need to set the following permission in your application:
I also created a LogEvent Object to parse events coming from the logcat: