What are you testing, really? This is the question you have to ask yourself when deciding to test certain pieces of code.
In an ideal world, having 100% code and branch coverage is nice, and having the ability to ensure that code is functional when rewritten is a huge benefit. However, one should never use code coverage alone as a suitable "happy" metric for test coverage.
In this case, you have to look long and hard at what you really want to inspect here. Given that you're newing up a lot of things, and that you'll have to mock out almost everything here, the realistic thing you can do is test the mechanical process of, "Does this object call this method with these parameters?" Frankly, that doesn't feel like a good test.
I would recommend that you exclusively test Demo#scan instead of the entirety of main, because:
scan is a method that requires a new instance of Demo, which is not easily injected into main. Yes, I'm aware you can use PowerMockito to accomplish this, but mocking out something that's newed up is a test smell to me. - Your application will fail to run if any of these are true:
args doesn't receive the right number of params - The path passed in through
args is invalid or malformed
- If you did go down the path of testing this, you'd start to realize that you're really testing a lot of library code and ensuring that the library code worked. That has some advantages, but in this case, the juice isn't worth the squeeze.
Demo#scan(Path, Path), this code just isn't that testable. The most meaningful unit test here (in my opinion) would be just to verify unhappy behavior (wrong # of args, maybe nonexistant paths). Otherwise you're really just testing your entire application.