1

I'm very new to this and I have a problem.

I'm writing test to a simple app I found on the Internet. Right now, this is how my code looks like

package com.example.test.test;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.Smoke;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.robotium.solo.Solo;
import com.example.test.MainActivity;
import com.example.test.R;


public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {

private Solo solo;

    public MainActivityTest() {
    super("com.example.test", MainActivity.class);

}
@Override
public void setUp() throws Exception {
    super.setUp();
    solo = new Solo(getInstrumentation(), getActivity());
}


public void testClickShowButton() throws Exception {
    solo.clickOnView(solo.getView(R.id.button1));
    assertTrue(solo.searchText("Witaj"));
}
public void testClickClearButton() throws Exception {
    solo.clickOnView(solo.getView(R.id.button2));
}   
public void testClickClickMeButton() throws Exception {
    solo.clickOnView(solo.getView(R.id.button3));
    assertTrue(solo.searchText("No hej co tam?"));
}


@Override
public void tearDown() throws Exception {
    solo.finishOpenedActivities();
    }

    }

And whenever I am running those tests, they are always running all at the same time. What I want to do is to just run one test - to click first button. Then, I wanna manually do second test - to click second button. Then again I wanna do manually third tests - to click third button. Unfortunately, Eclipse insists on running all tests.

Also, totally unrelated: I wanna write a test where Robotium will enter some data in TextBox and then Robotium will erase it. How do I do that?

user3271093
  • 191
  • 1
  • 1
  • 3
  • 1
    It seems you have not been able to search SO so far: http://stackoverflow.com/questions/13605774/how-to-run-a-single-method-in-a-junit-4-test-class. – Smutje Feb 16 '14 at 20:33

2 Answers2

1

If you are only using Eclipse to run your single test, then go to the junit runner view in Eclipse (the view that displays the result of your tests). Right click on the test you want to run and run it. It will be run and not others.

This can also be used to launch in your test in debug mode.

Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • This helped, thanks a lot! So I'm guessing, I can't add anything to the code to stop Robotium from running other tests? – user3271093 Feb 16 '14 at 20:41
  • Not really, maybe the best is to save 3 different configurations in eclipse and launch them all. But you should really consider creating a more industrial/automated setup so that you can do see with a single command line. – Snicolas Feb 16 '14 at 20:43
0

Also, totally unrelated: I wanna write a test where Robotium will enter some data in TextBox and then Robotium will erase it. How do I do that?

you cand use a variable to store your editbox:

EditText FirsteditText = (EditText) solo.getView(R.id.EditText01);
solo.enterText(FirsteditText, String.valueOf("10"));
solo.clearEditText(FirsteditText);

or not:

solo.enterText(solo.getView(R.id.EditText01), String.valueOf("10"));
solo.clearEditText(solo.getView(R.id.EditText01));
gionnut
  • 99
  • 3