I have a few questions relating to modelling my problem.I am working on a thesis project for Model Based Testing. Would also like to know from an expert point of view if I am taking the right approach fro modelling my scenario. I am modelling the UI of android applications , traversing through them , generating test cases and generating test codes for the espresso framework.
I would explain in simplicity the way I am modelling my system under test and to generate the test code for the test cases. (I am writing algorithms to generate the android code also). I am generating code for the android espresso testing framework. The structure of espresso always needs to find first the element to interact with. This is done with the “OnView()” method passing into in it parameters like withId(R.id.title) or withText(“Hello”) to find the element with the given Id or Text respectively. We then attach what the framework calls ViewActions or ViewMatchers to interact with the elements by performing actions or performing assertions respectively. Below is an example of an espresso test case, that finds a text view with a text “Lucky button” clicks on it and checks whether it is displayed.
@Test
public void test () {
onView(withText(“Lucky Button”)) //ViewMatcher
.perform(click()) // ViewAction .check(matches(isDisplayed())); // ViewAssertion
Simple Case Let us take an android application with two screens. Screen A and Screen B. Each screen contains different elements. E.g. TextView(Textlabel), ImageView(Image label), e.t.c. I use the state diagram to describe the states a screen can be in. For each state exists an activity diagram that describes the tests to be performed on elements e.g. TextView,ImageView. We group each test suite in swimlanes and represent the test actions with activity actions. But there is input information that is needed. For example, an activity action may be called isVisible to check visibility of the toolbar which is in the ToolBarDesign swimlane. To arrive at this action, we need information on the toolbar to first locate it and check its visibility. I do this by providing the necessary information on the transitions of the actions or states. Below is an example of a state diagram and an activity diagram describing the scenario.
This state diagram has 2 states. And transitioning from MainActivity to NewNote is a trigger called openNewNote with an action which is in the format of a freetext. The freetext action contains the necessary information by which I process and extract in my java framework for generating the piece of code like for the one above. In the framework, I first select the element with id title and then perform the click method. Also in the MainActivity state contains a sub activity diagram as described earlier. In this sub activity diagram, we give the opportunity for the person modelling (which we consider to be one who has knowledge of the espresso framework) to write activity actions for testing. Below is an example of the activity diagram for MainActivity which test the toolbar of the application and the login screen.
The toolbar transitions to the isVisible activity from the initial node. On the transition, we make a description as explained above on the transition on the state diagram. Here we get the freetext action “withText:Lucky Button,matches,isDisplayed” and then process it in our framework to get the code.
@Test
public void test () {
onView(withText(“Lucky Button”)) //ViewMatcher
.check(matches(isDisplayed())); // ViewAssertion
Questions. This so far works for the team as programmers are the ones modelling. I will provide a documentation for modelling the system. I would like to ask if this is a valid way of modelling and can be described in my research. And also if you have any comments or suggestions.
Without going into deep details, I would recommend going one step back and start broader:
The best way to start is to exercise on examples:
If you answer these questions you have also the answer if your approach is valid or has any errors, which I can't answer from what you presented.