0

I wrote a simple Android FSM app like described here.

And I need to test it with Robolectric and Mockito in Android Studio.
I've installed these plugins and read all the documentation, but have no idea how to test if() method using these frameworks.

Could you please advise, how I can do it?

The simplified example of my code in MainActivity.java is the next:

boolean stateOne = true;
boolean stateTwo = false;

public void onClickmethod_for_button (View view) {
    if (stateOne) {
        stateOne = false;
        stateTwo = true;
    }
    if (stateTwo) {
        stateTwo = false;
        stateOne = true;
    }
    displayState()
}

private void displayState() {
    final TextView stateTextView = (TextView) findViewById(R.id.current_state);
    String stateText;
    if (stateOne) {
        stateText = "State is one";
    } else {
        stateText = "State is two";
    } 
    stateTextView.setText(stateText);
}

enter image description here

ukroid
  • 1
  • 2

0 Answers0