Part V. Integration, Functional, Load, and Performance Testing

When Eeyore saw the pot, he became quite excited. “Why!” he said. “I believe my Balloon will just go into that Pot!”

“Oh, no, Eeyore,” said Pooh. “Balloons are much too big to go into Pots. What you do with a balloon is, you hold the balloon—”

“Not mine,” said Eeyore proudly. “Look, Piglet!” And as Piglet looked sorrowfully round, Eeyore picked the balloon up with his teeth, and placed it carefully in the pot; picked it out and put it on the ground; and then picked it up again and put it carefully back.

“So it does!” said Pooh. “It goes in!”

“So it does!” said Piglet. “And it comes out!”

“Doesn’t it?” said Eeyore. “It goes in and out like anything.”

“I’m very glad,” said Pooh happily, “that I thought of giving you a Useful Pot to put things in.”

“I’m very glad,” said Piglet happily, “that thought of giving you something to put in a Useful Pot.”

But Eeyore wasn’t listening. He was taking the balloon out, and putting it back again, as happy as could be….

“Eeyore has a birthday,” Winnie the Pooh, A. A. Milne

Today’s software applications are composed of an increasingly large number of different components. In addition to the different layers and modules within your application, you often need to integrate with databases, external applications, mainframes, and more. It is essential that these parts fit together smoothly and correctly.

This is the realm of integration testing. Indeed, if unit tests are a vital part of the testing process, there is nevertheless much more to testing than just unit testing. Integration testing, performance testing, and load testing also have a critial role to play. And they, too, can benefit from being integrated into the SDLC.

Unit testing generally refers to the process of testing an individual class or module, as far as possible in isolation from the rest of the system. For example, this can involve using mock objects or stubs to simulate interactions with other parts of the system. By reducing the interactions with other components, you make it easier to write tests ensuring that your individual classes perform as expected. If you aren’t sure that each component works precisely as expected, then you will have trouble guaranteeing the stability of the system as a whole.

However, unit tests are not the whole story. In the final system, the numerous classes and components interact with each other in often complex ways. The more interactions there are, the more complex the system becomes, and the more places there are for something to go wrong. Integration or system testing involves testing how the individual components of your application work together. For example, for a Struts application, you might use a tool like StrutsTestCase to test all the components from the controller layer, through the service and DAO layers, and right down to the database.

Functional testing involves using the system as an end-user would. In real terms, this involves testing the application via its user interface. Writing automatic tests for user interfaces has traditionnally been a thorny problem. We will be looking at two tools that you can use to integrate GUI tests into your automatic testing process. Selenium is a powerful, innovative tool originally developed by the people at ThoughtWorks that uses a web browser to run tests against your web application. And FEST is an equally innovative product that lets you integrate Swing testing into as part of your JUnit or TestNG tests.

If your application uses web services, these need to be tested, too. SoapUI is a powerful tool that can be used to perform functional and performance tests on web service–based applications.

Load Testing involves placing your application under continued stress over a long period of time, usually by simulating heavy use from many simultaneous users. The aim of the exercise is to predict the load capacity of your application (how many users can you handle?), and to identify performance issues, memory leaks, or other problems that would not otherwise surface until the application goes into production.

Performance Testing is done to ensure that your application meets the specified performance requirements, such as a minimum number of requests per second, maximum acceptable response time, and so on. We will be looking at how to use the popular JMeter tool to test both load and performance testing.

In many projects, performance issues are ignored until user acceptance tests make it obvious that some tuning is needed. Nevertheless, it is good practice to integrate routine performance tests into the standard development process. Regular performance tests in key areas can flush out performance-related design and architecture issues at early stages, when they are easier to rectify. Incorporating performance tests into unit test suites also helps with regression testing, and forces you to think about exactly how much performance you really need from your application: which parts of the code need to run fast, and how fast is fast? JUnitPerf is a JUnit library that lets you integrate simple performance tests directly into your unit test code.

With all this testing going on, you’re bound to find some issues. You may need to use some profiling software. For a long time, graphical profiling tools were the domain of commercial tools, and expensive ones at that! Recently, however, a number of open-source tools have emerged that can help developers analyze the performance (or lack thereof) of their Java application. In the following chapters, you will learn about open source Java profiling tools that can help to identify and correct performance and memory problems: first, the standard Java monitoring toolset, built around JConsole, and, second, the Eclipse profiling tools.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.128.145