I’ve been using Roboletric for about a year now on a client project and we recently ran into an issue when we started testing a new screen. We use Roboguice for dependency injection and when the view would get created under test the views that would get injected at normal runtime would not get injected during test. All of a sudden the injected view would be null.
The class looked like this:
The were trying to inject the LinearLayout and it was not working. The view was always null.
The view looked like this:
Notice the “a” in the “xmlns:a=” in the view. We changed it from the default “xmlns:android=”, doing this caused the injected views to be null. Why? Robolectric does not support anything but the default android namespacing in your layouts.
Therefore, always use “xmlns:android=” as your namespace declaration for your views if you’re using Robolectric and Roboguice.
Update: Thanks to Mike Burton, he pointed out that this is only the case for if you’re using “findViewById” and you’re using Robolectric. This has no correlation to Roboguice. We’re simply using Roboguice in my clients project and thought I’d make note of it. Roboguice is not doing anything it should not be doing.
kingwang says
Je ne suis pas un grand lecteur en ligne pour être honnête, mais vos sites vraiment sympa, keep it up! Je vais aller de l’avant et mettre en signet votre site pour y revenir plus tard. Tous les trucs best.pretty précieuse, dans l’ensemble je pense que c’est digne d’un signet, grâcemaillot football
rfytu674r6t says
I’ve been using Roboletric for about a year now on a client project and we recently ran into an issue when we started testing a new screen.
abercrombie et fitch