Closed glarimy closed 6 years ago
sir i am understand the test cases what the input to be given and what the expected output to be .but no idea on getting how to write the test cases in the form of coding.i am tried by revising some tutorials but no result.sir please give me a small explanation regarding the coding of test cases
Here is the implementation for the first case:
The get() method must return a question. The question id must be non-zero, the description must be a non-empty string, all the options must be non-empty strings.
@RunWith(AndroidJUnit4.class) class GlarimyQuestionServiceTest { Context appContext = InstrumentationRegistry.getTargetContext(); @Test public void testQuestion() { QuestionService service = new GlarimyQuestionService(appContext);
if (service.isConntected) {
Question question = service.get();
assertTrue("Invalid question is returned", question != null);
assertTrue("Invalid question id is returned", question.getId() >= 0);
assertTrue("Invalid question description is returned", question.getDescription() != null);
assertTrue("empty question description is returned", question.getDescription().trim().length != 0);
assertTrue("Invalid first option is returned", question.getOptionOne() != null);
assertTrue("empty first option is returned", question.getOptionOne().trim().length != 0);
// and so on ...
}else{
Question question = service.get();
assertTrue("Question available without connection", question == null)
}
}
Keep this class under androidTest/java/com/glarimy/quiz/service package Hope this helps!
thank you sir it will be helped to me to get the idea on test case coding.
sir when i am running the test case it is giving the following result
Process finished with exit code 1 Class not found: "com.glarimy.quiz.service.GlarimyQuestionServiceTest"Empty test suite.
i am still searching solution for this problem sir if any solution please suggest me.
Any update on this?
Currently working on this sir
Develop unit test cases for the following and check-in the code.
Complete the task by CoB today.