Testing

Published on January 2017 | Categories: Documents | Downloads: 41 | Comments: 0 | Views: 348
of 1
Download PDF   Embed   Report

Comments

Content

Unit Testing Unit testing is used to test a specific unit (class) in the application. Unit te sts should be written to test all the methods in the class including all excepti on paths in the methods. The objective of unit testing is to be able to quickly test any new code or changes to existing code without the overhead and additiona l time involved in tasks such as server configuration, services setup and applic ation deployment. Developer unit testing is critical since it is easier and chea per to find and fix bugs earlier in software development lifecycle (at coding an d unit testing phases) rather than in the later stages. JUnit is the popular testing framework used for writing unit tests. In JUnit tes ts, we simply instantiate the objects using new operator, without having to worr y about the container's JNDI resources and J2EE services such as resource poolin g, JDBC connection pools and JMS queues. We can also use testing techniques like Mock Objects to test the code in isolation. With unit testing, there is no need for any infrastructure setup for an application server or even a database serve r. There are some limitations to unit testing. Unit tests don't address the testing of functional requirements of the application. These tests only cover testing o f each module in the application. Also, we can't test scenarios like asynchronou s services which require JMS message queues configured inside the application se rver. But we should still be able to unit test as much application functionality as possible and use the in-container tests for only those functions that cannot be tested outside the container. Integration Testing Unit tests are very useful to test a module or class in isolation. But it's also important to do integration testing of the application to see how various modul es would work together when assembled in the integrated environment. Some functi ons that work fine at module level may not work correctly when integrated with o ther modules in the application. This scenario is very realistic in an agile dev elopment environment where different developers work on different parts of the a pplication at the same time and they need to merge code changes on a regular (in some development teams daily) basis. The integration tests include testing roun d-trip calls between client and service layers of the application. Most of the i ntegration tests usually run in the container. But to be truly agile, we will ne ed to run atleast some integration tests without any code deployment to the cont ainer. Integration tests are useful in DAO layer where the implementations of DAO inter faces cannot be unit tested effectively. Other objectives of integration testing is to test aspects such as remote service, state (session) management, web flow and transaction management. Integration testing has some constraints as well. I t takes longer time to run these tests. Since the application needs to be deploy ed inside Java EE container, there is also the server setup and configuration ov erhead involved in running these tests. It should be noted that integration testing is complimentary testing, not a subs titute for unit testing. Developers should first write sufficient unit tests for each java class in the application to achieve a good code coverage. At the same time, there should be enough integration tests written to cover different use c ase scenarios in the application that can not be tested with unit tests.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close