Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to test a custom view?

Tags:

There are several methods of unit testing in Android, what's the best one for testing a custom view I've written?

I'm currently testing it as part of my activity in an instrumentation test case, but I'd rather test just the view, isolated.

like image 747
futlib Avatar asked Feb 06 '11 14:02

futlib


1 Answers

A simple solution for the lack of a View-focused TestCase implementation would be to create a simple Activity within your test project that includes your view. This will allow you to write tests against the view using a simple Activity. Information on Activity testing:

http://developer.android.com/reference/android/test/ActivityUnitTestCase.html

like image 187
adam Avatar answered Oct 19 '22 15:10

adam