I'm working with Android in Netbeans and trying to decide which testing framework to implement for my application (I've never done TDD in Android before). I've been using this thread to look into different resources. I'm mainly familiar with whitebox, so I feel that I would be more comfortable with the built-in Instrumentation Framework. However, this is the first time I've heard of blackbox testing (Robotium), but it looks like it would be really useful as well. Is it common practice to implement both whitebox and blackbox tests? Or is only one really necessary? If both, what things are best to be whitebox tested and which are best to be blackbox tested? Or is this a totally useless question as it's completely application dependent and I should just pick one and start messing with it?
[EDIT]: I also want to add that I don't have any experience with JUnit since a lot of explanations seem to assume a basic understanding of it.
The two options you suggest (Instrumentation and Robotium) are actually pretty much the same thing, the closes to whitebox (or true tdd/unit tests would probably be roboelectric).
Is it common to do both? Yes i think that is usually a good approach normally you want to test things as low down as possible and then have fewer of the big blackbox tests, android doesn't make this the easiest if you ask me though so you may have more luck with the instrumentation/robotium tests cases as these are fairly easy to understand and they match up with what you can see on the screen fairly easily.
With regards to junit, android is bundled with junit3 which has much less features/complexity as jUnit4, and for the most part the only thing you will need to know is to name your testmethods with the word "test" in front of it e.g. public void testXXX().
Related
I would like to ask something interesting. When I am developing native android apps,and want to make sure that there no null objects,I use the debugger as shown.
So I put a break point in the line I want,I step over my code and the fun begins:). However,there is this TDD,which I have never used. Are they any specific tools for that? Is it more efficient?
Regards,
Theo.
TDD is generally a better approach as it stands for Test Driven Development and its idea is to have reproducable tests to validate your code against. A good way to do so is to read youself into JUnit which is also included in Android Studio.
EDIT: Also TDD is generally more Efficient as you notice errors much earlier and you write better code
I have googled about testing uni and systematic testing. But I am confused what exactly is systematic testing? I’m developing a mobile app and like to know how I can approach this technique testing.
Any ideas? Thanks in advance.
Systematic testing is a much more exhaustive means of debugging software. The goal is to test the software against a variety inputs in order to find as many defects/errors as possible. The difficult part about systematic testing is usually coming up with the inputs/situations to test against (especially in the case of Android development, as a number of things can go wrong). Does your app work correctly after configuration changes? Do your EditText boxes specify the correct inputType? Systematic testing provides a means of uncover such errors, and often results in a more secure/robost application.
The Android team provides several tools that can automate this kind of testing (although obviously there is no guarantee that it will cover ALL of the cases). One such tool is monkeyrunner. Check out the Android developer's guide on testing for more information.
A systematic test is a test, in which
the setup is defined,
the inputs are chosen systematically,
the results are documented and evaluated by
criteria being defined prior to the test
I have been developing Android application for a small company and during the development process we need to do repetitive testing of some modules, So i searched tools for doing automation testing (unit testing) of the app. Android has a unit test tool however to write those test cases will itself take more time then to actually test it by hand.
I found some apps which do some great stuff and provide good charts for example Robolectric, robotium, fonemonkey4android, but am confused to what to be used, any one with any experience with the same can help.
I checked for previous questions on the similar terms like below
https://stackoverflow.com/questions/522312/best-practices-for-unit-testing-android-apps
But all the threads are very old and not so informative to decide on which to choose..
I think first you need figure out which part of your code you want to test.
For codes which doesn't related to user interface, you can test them with Robolectric. With Robolectric, the unit test code is the same to those written for java application. But it's not suitable for test ui components.
If you want to test ui, then you can choose robotium. But i always doubt whether it's worth writing tests for ui, they change too often..
I am a newbie to android. And feels like TDD can reduce developing time a lot. But after learning android's junit test framework, find it a bit difficult to achieve the goal that write test before coding. Especially when i want to test module like adapters, views and databases. So i wonder it's because i am not familiar with android test framework enough or android is not suitable for TDD.
Sure.. :-) In general TDD approach can be used for developing Android apps too. But not always worth.
It sometimes needs more effort, so you should consider the pros and cons carefully. I think you should not force to do every little part of your development process to be test-driven, but consider using it every time before you start typing. I prefer mixing TDD with test-last approach.
You can try by using robolectric https://github.com/pivotal/robolectric
and here is sample https://github.com/pivotal/RobolectricSample
I have a fairly basic application. I'm loading it up on 2.1+ on emulators and 2.3.3 on an n1 and basically just making sure everything looks right and does what it's supposed to.
I was reading about activity testing on the dev site and it talks about creating test applications and such. I don't get the point of testing whether a textview = a resource string that you set it to or not.
How deep do you really need to test fairly basic apps before letting other people use them. Is there really anything that I won't catch using emulators and an n1 that test applications and such will?
The general rule of thumb is test anything that is complex enough to go wrong. If you don't have alternate resources, it is generally too simple to break.
Creating programs to test other programs? The only purpose I would see to this would be testing security of your app.
I've never had to create anything like this, and I publish many types of apps on the marketplace.
In my opinion, it is always best to do testing on an actual phone. Emulators arnt fully functional and possibly slower than the phone itself.