How to structure MVP for testing?
- View
- displays the data and communicates user actions to the Presenter
- listens to user interaction and passes it to the Presenter
- Presenter should not know anything about Android based (Context, Activity, Toast, Intent, startActivity…)
- decides what to do with logic inside the listener
- gathers data from the model
- tells View what to displays
How to setup JUnit
- Set the Project explorer (left hand window) to display ‘Project’ mode. Tap the little drop-down at the top left and select ‘Project’
- Right click the ‘src’ directory, ‘New -> Directory’.Call new directory androidTest
- Right click androidTest and add a ‘java’ directory. It will appear in green (indicating it’s a test src directory)
- Now right-click again and add a package, e.g. com.mycompany.myapp.tests
- Add a new class that extends AndroidTestCase
How to setup Expresso
Test file can’t be in the same folder with JUnit Test. They must be in Application Test
Leave a Reply