Unit testing Video Service class I wrote my first unit testing code on a service class using Mockito. The code looks like this:

// Test Class
public class TestVideoService {
    private VideoService videoService;
    @Mock private VideoRepository videoRepository;
    @Rule public MockitoRule mRule = MockitoJUnit.rule();

    @Before
    public void setUp(){
        this.videoService = new VideoService(videoRepository);
    }

    @Test
    public void testGetAllVideos() throws Exception{ 
        when(videoRepository.findAll()).thenReturn(new ArrayList&lt;Video&gt;());
        assertEquals(new ArrayList&lt;Video&gt;(), videoService.getAllVideos(), "tested");
    }

}


I also have several questions. I feel like I'm just comparing the same mock values (ArrayList of Video) – what's the point of doing this, or am I just doing it the wrong way?

Some other classes:

@Service
public class VideoService {
    @Autowired
    private VideoRepository videoRepository;

    public VideoService(VideoRepository videoRepository){
        this.videoRepository = videoRepository;
    }

    public List&lt;Video&gt; getAllVideos(){
        return videoRepository.findAll();
    }
}

@Repository
public interface VideoRepository extends JpaRepository&lt;Video, Long&gt; {
}
Welcome to code review and thanks for sharing your code.

When writing UnitTests keep in mind that they are documentation. 
Test code has less restrictions for identifier names.
This means that method names are usually longer and you should not "shorten" your unit test methods.


The test name should describe the expected behavior in detail

@Test
public void getAllVideos_returnsCompleteListFromRepository() throws Exception{ 
    // ...

A unit test always has three parts: arrange, act and assert. 
You should always have this three parts visible in your test methods. 

In your example you do the act part implicitly in the assert line. 
This prevents you from introducing variable that could give useful information about the result:

@Test
public void getAllVideos_returnsCompleteListFromRepository()
    // arrange 
    List&lt;Video&gt; allVideosInRepository = new ArrayList&lt;&gt;();
    when(videoRepository.findAll()).thenReturn(new ArrayList&lt;Video&gt;());
    // act
    List&lt;&gt; allVideosFromRepository = videoService.getAllVideos();
    // assert
    assertEquals(allVideosInRepository, allVideosFromRepository, "tested");
}


For the same reason the String parameter of the assert* method should always be a useful hint in case the test fails because it is part of the error message:

    assertEquals(allVideosInRepository,
                 allVideosFromRepository,
                 "is same object");






  I feel like i just compare the same mock values ArrayList of Video and what's the point of doing this or i just do it wrong way.


This is not a problem of your unit tests but of your current design. 

For the time being your VideoService class is nothing more than a facade to a Collection, there is no business behavior (yet) to be tested.