Sorry if this is dumb but I just got a job and introduced to my first assignment yesterday. The task at hand was to implement unit tests using the mockito, powermockito, and junit framework for about 4 classes, each with about 300 lines, to be done by end of day Tuesday. I have 2 yeo but I've never done unit tests before, and I really don't get what the purpose of them is, but I was told the assignment was given "so that I can better understand what's going on within the codebase." While this makes sense, what I'm finding is that I'm more struggling to learn about what unit testing actually is, what I'm supposed to test, and what the actual point of it is. It's also a bit interesting because people with less software dev experience and exposure are introducing this to me, and I'm really not getting what the concepts are for - it seems like a special type of programming that I've just never seen, but also seems arbitrary to some degree, but it also seems simple for most devs just getting introduced to all of it.
So I go into one method, and I test it out. It's like a response.getContent(), and I do when(respones.getContent()).then(mock(Content.class)) or something, and then I'd go into the code and behave as a compiler testing out each of the individual components. But... obviously they all work. They all have return types that work, and that behave as actual classes. But then there are if statements to test, for loops, array lists, and it seems as though JUnit testing doesn't deal with most of that stuff until you get to an actual method call. Then once you get to that method call, you go into that method, and you write tests for that method in the function that has an actual @Test annotation. Do I have that right? Anything I'm missing?
I'm just unsure as to what the conventional wisdom is behind unit testing. If something were to break, I could test it manually, or test an endpoint in Postman, but these unit tests seem like they're made up, or that the only point of them is to just "become the compiler" and better understand the code that way. Even the other unit tests I've seen in this project seem really hand-wavy, and don't even seem to test everything. Then it would also seem that unit tests don't serve any inherent purpose, since they're static, and you can't see what's going on within the code in a more dynamic setting, like when it's live.
Could someone help my understanding? I am having some trouble understanding what value unit testing actually brings. Thanks.