austgl / robotium

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

How can Solo work when using in external class #45

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Create a common class such as "common.java" with using solo to do something.

In the test case class there is a test case with call a method which using solo 
from the "common.java" class. 

However, it does not work when running this test because it's does not 
recognize the solo.

Please help me to solve this problem.
It's appreciate if there is any example.

Thank so much.
Hakuen

Original issue reported on code.google.com by entrang2...@gmail.com on 14 Dec 2010 at 9:59

GoogleCodeExporter commented 9 years ago

Original comment by renasr...@gmail.com on 14 Dec 2010 at 10:02

GoogleCodeExporter commented 9 years ago
u should pass the solo object or u have to create solo object in your 
Common.java

Example:

tescase.java has your test method

msolo = Solo(getInstrumentation(), getActivity());

test1() {
    Common.clickontext(solo,text);
}

Common.java should contain.

public static void clickontext(Solo solo,String text) {
  solo.clickOnText(text);
}

Original comment by anandpai...@gmail.com on 14 Dec 2010 at 11:41

GoogleCodeExporter commented 9 years ago
Please see above answer.

Original comment by renasr...@gmail.com on 16 Dec 2010 at 3:53

GoogleCodeExporter commented 9 years ago
I did write my tests as suggested by Anand. In the above scenario let's say I 
have created a bunch of methods in Common.java and also I created multiple 
classes similar to Common.java which provide different reusable functionality.
Each time I invoke a method in Common.java or other classes I am passing solo 
object(from testcase.java), instead is there a way to create a solo object in 
Common.java.
Anand did mention that this can be done but an example/suggestion would be 
great.

Original comment by kpsrika...@gmail.com on 24 Nov 2011 at 10:17