What to test with JUnit

Viewed 30

Premise I am about to try my hand for the first time in testing a university project in which I was thrown without the slightest experience, finding myself in front of a gigantic problem: How and what should I test

Mine is a simple app that communicates with a movie database and has an MVVM structure.

These are my packages: activities, adapters (for recycler views), fragments, models, repositories, request, response, utils, viewmodels

My question is should i test everything? For example do activities or fragments have to be tested with Espresso or also with JUnit?

1 Answers

You should test everything that contains logic. Since UI components and things like database/filesystem/network access are usually hard and/or slow to test, you should make sure that the logic is not in these components. Just from the name of your packages it is hard to tell which need testing.

Rule of thumb: Does it contain loops, condition and other nonlinear code? Test it.

Related