Hello. I've cloned a project that was not developed by me so I'm not that familiar with the codebase, yet. Then I've tried to build it using "mvn install". After like 5 minutes of waiting and seeing stacktraces on the screen maven said the build is not successful because tests failed. Note, however, that our Jenkins pipeline build is successful which I'll get to later.
I then started looking into the src/test/java directory and found that there are both integration and unit tests. The integration tests rely on some services (RabbitMQ and MySql) which the original developers were running in Docker containers I'm guessing. These developers are not working with us anymore so I can't ask them.
I would like to restructure the codebase but before I do that I wanted to advice with you guys about the following things:
1. It seems to me that if somebody clones a project and run "mvn install" then it should run successfully to begin with. That's my opinion. However, on the other hand, maybe the developer should follow instructions such as run docker-compose in the README.md file to get the "mvn install" to work (just FYI: there isn't a README.md file at this point).
2. I happen to use IntelliJ IDEA IDE (but I think it shouldn't matter what IDE a developer uses). I right-clicked on the src/test/java directory and clicked to run all tests. Of course, the integration tests failed and in general all tests took very long time to run. I was able to by-pass this issue to run only unit tests by putting the pattern "^(.*)Test$" in the IDEA run configuration which now runs only unit tests.
1. The integration tests have an extension "IT".
2. The integration tests are also located in a sub package that has the name "integration".
3. There are some unit tests that are kind of slow (take like 60 seconds to run).
I will be investigating these long-running unit tests so that's a separate issue.
But my biggest concern here that I want to ask advice on is: should developers have to configure in their IDE to avoid running integration tests. Maybe the integration tests should be in a different directory like for example src/integration/java (just an idea).
Sorry if this is a lot of information. I just want to discuss this issue with others as I'm thinking of a good way to restructure this project. I'm not saying that integration tests don't add value but during development I (and I'm sure other developers, too) want to run unit tests frequently so they have to run super fast. And once in a while to run integration tests because they run very slow.
Also, the Jenkins pipeline should obviously run both integration and unit tests but that's a separate issue.
Cloning the repository and building should run the unit tests just fine.
Integration tests are different. It's very common to have stubs for things you aren't testing, services that are assumed to be running, test code to emulate missing systems etc. This should all be covered in a README. The README should be comprehensive enough so you know exactly what you need, which version(s), where to get them, how to start/stop them, etc.
I prefer a setup like the following:
* Unit tests go in src/test/java, their resources in src/test/resources. Maven knows how to handle those.
* Integration tests go in src/it/java, their resources in src/it/resources. These folders are added to the build using the build-helper-maven-plugin in a separate profile. This profile can be activated when necessary, but by default it's not activated.