BreadcrumbHomeResourcesBlog Testing Microservices In Java December 11, 2019 Testing Microservices in JavaJava TestingMicroservicesBy Curtis JohnsonMicroservices are undoubtedly impacting the way in which applications are created today, as well as how we continue to manage our large existing applications. They provide unique opportunities for companies to create a more scalable version of their applications which can translate into highly performant applications. Due to the functional and operational complexities of microservices applications, testing microservices in Java applications is a point of emphasis for development teams.In this blog post, we’ll look at how Java applications have been tested historically, how that has changed with microservices adoption, and outline some of the major tenets of testing Java microservices.Table of ContentsA Short History of Java Application TestingTesting Microservices in Java ApplicationsTable of Contents1 - A Short History of Java Application Testing2 - Testing Microservices in Java ApplicationsWant more data on how your Java development peers are using microservices and the challenges they present? Find it in our 2024 Java Development Productivity Report.Get Your CopyBack to topA Short History of Java Application TestingIn the past, testing was often delegated to specific people who would focus on testing and releasing the application. It required testing massive applications with a large variety of complexities — making testing the application a convoluted and difficult process. More importantly, testing was difficult to scale — with a constantly changing group of engineers working on the project. When one person left the team or the company, the transition process was often painful and strenuous.Vertical Organization of Development TeamsOften the break-up of those testing teams was done vertically so the application testing process wasn't likely to be understood by the developers, and vice versa. This resulted in people only knowing specific parts of the application. While there are some natural advantages to this approach, it also has some glaring weaknesses.Take for instance a junior developer: They get incorporated into the development team in a position that doesn't pose much risk to the application. But, because they are only working on one part of the application, they are never developing with the larger scope of the application in mind. Not because they don't want to, but because they are not seeing the larger application and how it functions together. Because of this, they are less likely to understand how their code may negatively impact application functionality or performance.That's especially true for microservices, where individual services can impact performance in other services — and in the combined application.Back to topTesting Microservices in Java ApplicationsDue to the increasing adoption of microservices for a wide variety of Java applications, the need for robust testing has become more important than ever. Part of that is due to the increasing responsibilities for developers, but the more significant cause is that microservices applications can get complex quickly. That means that individual containers and the application both need to be continually tested to ensure success during microservices deployment.One of the reasons that testing microservices is so difficult is because of the complications that come to play. Each service has its own built code base, database schema and dependency management. Because of these varieties, you often test the application locally by running up all these services and then running your testing options for your code.Getting the services all up and running on your machine can take quite some time before you are able to test your application. This is often broken down into a couple of testing processes used in microservices: unit testing, load testing, end-to-end functionality testing, performance testing, and others.Unit Testing Microservices in JavaWhen most think about testing an application of any kind, unit testing is the core of all software testing. The practice of unit testing has been tested and tried for years. Now when it comes to microservices, unit testing is critical to breaking down the application even further. By targeting small testable parts of the application, unit testing proves critical when identifying specific interactions your application is making.Martin Fowler breaks unit testing up into two main categories:Solitary unit testing - Unit testing is not done against real information stored in your database. This is typically done to run tests that won’t cause the entire application’s tests to fail.Sociable unit testing - Unit testing is done against real information stored in your environment. Running unit tests this way often results in more issues appearing through the testing process than ideal in a local dev environment.Load Testing Microservices in JavaLoad testing is the process of running your full application in an environment as closely associated to your production environment as possible. This is something that must be run later in the testing process. It is typically focused on seeing how the application’s services work together.Load testing is meant to be non-functional testing to best understand how your application works at normal and peak conditions. Understanding how many users can simultaneously use the application is critical to ascertaining the maximum operating capacity.Automated Testing in Java MicroservicesOne of the biggest benefits for testing Java microservices is that many of the latest automation and testing technologies have versions developed specifically for microservices. In our recent article on Kubernetes vs Docker Swarm for container orchestration, we pointed out a free technology trio (Kubernetes, Istio, and Jenkins X) that can be used to create complex, automated, and disposable, testing programs that help applications to stably scale or release new features via canary release.Once deployed, these test automation techniques are a veritable holy grail for developers who want to produce stable and scalable microservices applications. With this level of automation used for your microservices, you are going to be able to get a detailed grasp of your application. The problem that comes alongside this set-up is the set-up itself.It is relatively easy to set up and maintain this automated testing process when you start your application with microservices in mind. But the reality in the microservices community is that the majority of these microservice applications are transitioned from large monolithic applications — making this automated testing process difficult to perfect. This results in most of these applications providing elements of automated testing but still requiring a plethora of other more manual testing practices within them.End-to-End Functionality Testing Microservices in JavaIn microservices, functionality goes beyond the functions performed by individual containers. Testing the overall functionality of the application, and developing the application in a way that makes it testable throughout its lifespan, is an important consideration for developers.End-to-End functionality testing is focused on the customer’s direct experience with the application. Teams do not always go through this process before committing code to production but often things that aren’t caught through the more automated processes are identified during this process.Performance Testing Microservices in JavaWith DevOps changing how companies approach application testing, developers are increasingly responsible for the performance of their code as it applies to the entire application. But, with the emergence of microservices applications, performance issues can be harder to diagnose and fix. That’s especially true as microservices applications become more mature and, subsequently, more complex. So, how can developers get better performance during microservices application development? Additional ResourcesLooking for additional microservices resources? Our recent webinar, Improving Performance in Java Microservices, is a must-watch.ArticlesPerformance Testing Microservices with JMeterDeploying Microservices in JavaPerformance Testing vs. Load Testing vs. Stress TestingWhen to Use Microservices in JavaTesting Microservices in JavaPopular Java Microservices FrameworksKubernetes vs Docker SwarmOn-Demand WebinarsImproving Performance in Java MicroservicesMicroservices vs Mini vs MonolithMaking the Move to MicroservicesIgniting Your Digital Transformation With MicroservicesBack to top
Curtis Johnson Product Manager for JRebel, Perforce Software Curtis Johnson is a product manager at Perforce, where he spearheads the development and enhancement of JRebel. With a keen eye for optimizing software solutions, Curtis has consistently driven the evolution of JRebel to drive Java development productivity during his decade-long tenure. Under his guidance, JRebel has solidified its position as a necessary solution in the Java ecosystem.