Question: Write Android App Unit test cases USING JAVA for the following: 1. Check if the submit button is clicked before selecting a radio button. if
Write Android App Unit test cases USING JAVA for the following:
1. Check if the submit button is clicked before selecting a radio button. if no radio button is clicked TextView 'errorMessage' should be set to "Please select an answer"
2. Check if the radio button selection is correct. If it is correct set TextView 'Result' to "Your are correct". if(radioButton.getText()== correctAnswer){ set 'result' to "Your are correct" }
3. Check if the score is increased by 1 points when answer is correct (When radio button.getText == correctAnswer)
Here is an example for reference:
| @Test | |
| public void clickSecondOption_CheckCorrectAnswer() { | |
| onView(withId(R.id.start_button)).perform(click()); | |
| onView(withId(R.id.radio_second)).perform(click()); | |
| onView(withId(R.id.radio_second)).check(matches(isChecked())); | |
| onView(withId(R.id.radio_second)).check(matches(not(withText(ANSWER)))); | |
| } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
