JGeovani / robotium

Automatically exported from code.google.com/p/robotium
1 stars 0 forks source link

Make Robotium follow Singleton pattern #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Actually Robotium wraps UI interactions using the Android's Instrumentation. So 
once it has access to instrumentation, it can jsut use it.

In my test cases there is a need to have Robotium instance in multiple classes 
and I dont want to instantiate it multiple times as I dont want to waste memory 
by carrying more than one robotium isntance for the entire lifecycle of my test.

Could it be possible to make Robotium singleton so that other can also benefit 
from it.

Original issue reported on code.google.com by aman.bha...@gmail.com on 24 Jan 2011 at 10:38

GoogleCodeExporter commented 9 years ago
Also when I think more about it, a singleton pattern will help in finalizing 
all Activities,  because the way Robotium finalizes is by keeping track of all 
the activities it has encountered during the life time of a test.
Now with more than one solo instances in a complex test case, not all instances 
will know of all the activies depending on which instance is used where in the 
test case.

Obviously test case will call finalize on one of the solo instances which might 
not clean up all the activities. You can argue that I will make activitylist 
static, but I believe that making Robotium follow Singleton would be better.

Thanks

Original comment by aman.bha...@gmail.com on 24 Jan 2011 at 10:48

GoogleCodeExporter commented 9 years ago
You can easily just use one instance of Solo if that is what you want. You are 
not required to make new instance for every test case. 

Changing it to a singleton will introduce a lot of issues, it would break all 
backward compability. Thanks for the idea though. Its an interesting point. 

/Renas

Original comment by renasr...@gmail.com on 25 Jan 2011 at 6:12

GoogleCodeExporter commented 9 years ago
How can we use one instance solo for every test cases?  Would you show the 
sample code,please?

K

Original comment by kuniaki....@gmail.com on 5 Dec 2012 at 1:57