Ideally, we want our tests to run every time somebody pushes code to the central code repository; part of doing this is ensuring that it's very easy to run our tests. If somebody can just check out our code base, run one command, and have all of the tests just work, it means they are far more likely to run them.
We are going to make this easy by using Apache Maven. To steal a quote from the Maven documentation:
"Maven is an attempt to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices."
- https://maven.apache.org/guides/getting-started
Maven is a tool that can be used to build Java projects and manage project dependencies (including downloading any dependencies that you require) and is used in many companies as part of the standard enterprise infrastructure. Maven is not the only solution to this problem (for example Gradle is quickly gaining popularity and traction) but it is one that you are most likely to see on the ground and one that most Java developers will have used at some point in their career.
One of the major plus points is that it encourages developers to use a standardized project structure that makes it easy for people who know Maven to navigate around the source code; it also makes it very easy to plug into a CI system (such as Jenkins, or TeamCity) as all the major ones understand Maven POM les.
How does this make it easy for developers to run tests? Well, when we have set our project up using Maven, they should be able to check out our test code and simply type mvn clean install into a terminal window. This will automatically download all dependencies, set up the class path, and run all of the tests.
It doesn't really get much easier than that.
Comments
0 comments
Please sign in to leave a comment.