I have written an Android application. The application requires a Bluetooth connection to a very specific piece of hardware, currently a prototype. The only way I can test the app at present is to drive hundreds of miles to see if it works. If I end up with an ANR it can be very embarrassing in front of my client. The connection type and the mechanics of this app are very tightly tailored to this hardware. I am not permitted to bring a laptop, root my phone, or connect to any other device on the premises.

Is there any way to test this application at home, or step through the activities to ensure I don't have another ANR on the second activity while the client looks at me horrified?

I should point out I am not an experienced programmer and this is a new idea that I am helping someone with, as hiring staff is not on the cards at present, so I am undoubtedly missing some of the very basic concepts of developing this.

  • 2
    Is the interface too complex to mock it? It should be possible to mock at least basic functionality of the device.
    – MrSmith42
    Oct 8, 2013 at 8:37
  • @MrSmith42 I had not considered that possibility, can I mock sending and receiving data over Bluetooth? At current I cannot get past my first activity as there is no paired device and no open Bluetooth serial connection.
    – RossC
    Oct 8, 2013 at 8:40
  • To elaborate I need the AVD (or physical phone) to connect over a fake Bluetooth connection and then send out the relevant data from my phone. I know the receiving data part works fine so I don't even need anything back in return. I just need to (just as an example) press 'A' and my phone to send out the byte stream 'A' to the hardware. What happens after that is up to the hardware. I cannot test this as I said, as I cannot make a connection. I drove over yesterday, connected to hardware, opened my first activity hit the first button and black screen, absolutely sickened.
    – RossC
    Oct 8, 2013 at 8:49
  • 1
    What is ANR? I am assuming that you do not mean Alpha Natural Resources or Adult Nursing Relationship (which is what Google came up with)? Or an AVD for that matter? Oct 9, 2013 at 17:30
  • @MarjanVenema Sorry, should have clarified. ANR is application not responding, or force close by another name. It is when your application crashes out completely and returns you to the homescreen. It looks bad in front of a client. AVD is an Android Virtual Device that you can run to test your application on a few different virtual devices. It's a fundamental part of the Android testing process... until this situation emerges(not being able to mock up the hardware the device will connect to via BlueTooth). I hope that clarifies.
    – RossC
    Oct 11, 2013 at 9:40

2 Answers 2


As @MrSmith42 suggested, you should do the best you can to mock the interface. You don't need an actual bluetooth connection in order to mock it. Call an interface. That interface, in debug, sends what you'd expect for a given input. When not in debug, it performs the actual work of sending and receiving the data. You be sure that what you send to the interface and how you handle its output works. Sprinkle a generous bit of error handling, managing errors you can manage and logging the rest, and you have yourself something you can test directly at the client.

The only possibility for error at that point lies in the difference between how you expect the device to handle and how it actually behaves, and in my experience, hardware is never entirely reliable. So do be sure to have a blanket error handling mechanism for something you don't expect that would at least dump some sort of log.

  • 1
    Your advice is excellent, unfortunately the actual coding of this is way beyond my skillset. I will have to hand this over to a full time developer. Thank you very much for your answer, I will mark as the accepted one as it is the best way to do it. I just have absolutely no idea where one would even begin to write a mock interface, and it has become clear to me I'm in way over my head here. Thanks to both of you. Just FYI the interface is just a serial Bluetooth connection, I will only be sending Strings (as bytes) over the connection.
    – RossC
    Oct 8, 2013 at 9:14
  • 1
    I just wanted to add one last thing, if anyone else comes across this question and is more knowledgeable than I on these things there's some great links for mock interfacing etc here: stackoverflow.com/questions/3337505/…
    – RossC
    Oct 8, 2013 at 9:25
  • @RossC Well I say "interface", but the interface is how you define it. In production, the interface itself passes data via bluetooth, but that doesn't mean your interface must work precisely in the same way. I meant more along the lines of what commands you want to send to the device and what kind of output you can expect to receive if fail/success. That sort of thing.
    – Neil
    Oct 8, 2013 at 13:32
  • 1
    +1: "Interface" may sound like its code should have been clean and simple, but in this case what you want is actually a "Hardware abstraction layer" in which you put all sorts of device-specific hacks, workarounds, or simply nasty code necessary to get every device working. Its job is to keep the plumbing sewage away from the sparking-clean bathroom. Don't expect clean code in this layer.
    – rwong
    Sep 24, 2014 at 20:00
  • @rwong Absolutely. A clean interface that a program can use to talk to hardware is the hallmark of a well-written driver. The rest of the program shouldn't have to know the abstracted details.
    – Neil
    Sep 24, 2014 at 20:16

I think this is a project management issue, not so much a software development issue.

You should have a week or two with access to the device (on your client's premises or at your office) to evaluate the basic behavior of the device and to see how it interacts with your software. Afterwards you can mock the interface and develop the functionality at home and again a week of integration tests.

When you interact with hardware the need and the value of integration tests cannot be underestimated. If integration tests are not possible, your project will fail. Programming blindly towards a hardware you cannot test does not work.

You have to discuss this issue with your client.

  • 1
    Thanks for your feedback Simon. I think that's an inevitable conversation. There has to be some compromise or the end result could be potentially worse than useless. I want to exhaust the avenues available to me and be able to show I have done my research. I will also suggest again, that I be given a laptop they approve of and then I can run the app with the full ADK at my disposal when I am integration testing. I appreciate it!
    – RossC
    Oct 8, 2013 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.