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

Java Unit Testing in Java What to Test What Not To Test

Lewis Cowles
Lewis Cowles
74,902 Points

Android and what not to test

So thinking specifically about Android, or any third party library dependant code, if our classes and libraries are fully testable without our app, is it good practice to not worry about testing these libraries (things like INTENTS in android I'd have no idea to test for example) I'd especially value input from Craig Dennis on when not to test a framework as well as anyone fluent in Android, or a Java framework where the framework itself should avoid being included in tests and how to manage (I think composing where your app controllers meet models is probably a good idea to borrow from MVC terminology)

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Lewis Cowles !

You definitely want to keep your unit tests testing units of work only. The goal is to get your code to be isolated. There are lots of great mocking tools for Android, one that I played with ever so briefly is Robolectric. I was impressed with it's approach and the handling of system events. You are correct, you definitely do not want to test 3rd party libs, they have probably already done that for you, and that's just duplicated work.

Remember that there are different levels of automated testing. There are also functional tests sometimes referred to as integration tests. These are usually long running tests that you'd want to kick off on a server maybe triggered by a Continuous Integration. The goal is to test that your units work together!

I think we may have Unit/Functional Testing of Android apps somewhere on the request board already, but if not, psst Ben Deitch .

Hi Craig,

In regard to "I think we may have Unit/Functional Testing of Android apps somewhere on the request board already", I believe you are talking about the Trello board for planning the roadmap:

https://trello.com/b/fFYx3BCO/treehouse-android-content-roadmap#

How do I know about this board? Am I a moderator or a psychic?

No...I've just gone through and read ever single forum thread/post (and bookmarked quite a few of them)

Specifically here's a forum thread from 9 months ago (entitled: "Course Request: Unit and UI testing on Android "} where that link came from:

https://teamtreehouse.com/community/course-request-unit-and-ui-testing-on-android


I tend to think of Ben Jakuben (vice Ben Deitch) in connection with this Trello board (since he's had the majority of "activity" on this board).


It would be ever so nice if this Trello link could be a "sticky" at the top of the forum's community page..but then again it would be nice if the forum actually had stickies,

....as a moderator recommended some time ago:

https://teamtreehouse.com/community/would-be-really-nice-to-see-forum-stickies-for-common-problems-on-the-forums-be-implemented

Of course I've also mentioned forum stickies as Suggestion #1 on this page:

https://teamtreehouse.com/community/some-questions-about-treehouse-including-internals-and-a-few-suggestions

...but like nearly every other suggestion I've made to TeamTreehouse I'm pretty much still waiting...

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hello again James....

I do mention the Java Content request Trello board in every course since it's inception and in just about every email that I send out. I added your IntelliJ plugin request there, we'll see how many votes it gets. But you are right, maybe some non-psychics aren't sure what I'm talking about and I should've included the link. I knew that Lewis already is aware of the board because he has requested a few that we've turned, or are turning into workshops. And obviously Ben knows about the board too.

The closest thing that we have to Stickies is Featured posts. In fact, when we announced the Trello boards, the post was featured.

As far as that long post of "requests" from you, I did run across that before but was unable to get through to the end. With all the links you usually end up including I end up getting lost in an Internet hole trying to understand what you are attempting to state. Maybe with some time over the break I'll be able to power through it. If I do, I will put comments there.

Hoping you have a happy holiday!