1 / 15

J-UNIT TESTING IN ECLIPSE

J-UNIT TESTING IN ECLIPSE. Mahesh Raju Deshpande. BENIFITS OF UNIT TESTING. 1. Facilitates change : Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly.

amalie
Download Presentation

J-UNIT TESTING IN ECLIPSE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. J-UNIT TESTING IN ECLIPSE Mahesh Raju Deshpande

  2. BENIFITS OF UNIT TESTING 1.Facilitates change: Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly. 2.Simplifies integration: By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier. 3.Documentation: Unit testing provides a sort of living documentation of the system. Developers looking to learn what functionality is provided by a unit and how to use it can look at the unit tests to gain a basic understanding of the unit's API.

  3. INTRODUCTION TO JUNIT JUnit is an open source Java testing framework used to write and run repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. Developed by Erich Gamma and Kent Beck. Key element of Test-driven Development. JUnit test generators now part of many Java IDEs (Eclipse, BlueJ, Jbuilder, DrJava).

  4. LET'S GET STARTED WITH THE ACTUAL PROCEDURE (1).Firstly create a code to be tested. (2).Separate the unit test code from application code. Select the project-->File-->New-->Source Folder-->give it a name(I have named it “test”)-->Finish.

  5. (3). Put test classes into same package as the code being tested. Select src folder of test classes-->File-->New package-->enter the package name-->Finish.

  6. (4). Now create a JUnit test. Select the newly created package-->File-->New-->JUnit Test Case then enter the Name of the Test and the Class under test-->Next

  7. There are two versions of JUnit as can be seen in prev slide, JUnit 3 and Junit4. If we choose JUnit 3, we have to add a prefix “test” to a method name. In JUnit 3. you could choose from several runners: text, AWT, or Swing. JUnit 4 only uses text runners. JUnit is an external library and hence we have to add the JUnit library to the build path. JUnit 3 and JUnit 4

  8. Select methods for which test method are to be created.

  9. (5).We have to modify the test cases to actually test the class to be tested.

  10. (6). Once the test methods are modified, we can run them. Run-->Run As-->JUnit test. Then Select the Eclipse JUnit launcher-->OK.

  11. Thank You

More Related