Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Testing in Android Unit Testing Testing the Presenter

Kevin Walker
Kevin Walker
2,354 Points

Error in @Before Setup Method

I know this is an older video (I'm on AS 3.1), but in the @Before setUp method in the MainActivityPresenterTest class, I am getting this error:

MainActivityPresenter in MainActivityPresenter (com.treehouse.testingbase.MainActivity) cannot be applied to (com.treehouse.testingbase.MainActivityView).

I did try casting the view variable as MainActivity, which will remove the error above. But when running test I get a classCastException.

1 Answer

Seth Kroger
Seth Kroger
56,414 Points

You haven't show any code to diagnose but it sounds like you have your classes a bit mixed up, or one of the classes isn't imported. MainActivityPresenter should be in its own class/java file and well as MainActivityView.