1 / 8

Software Design– Unit Testing

Software Design– Unit Testing. SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests.

hymand
Download Presentation

Software Design– Unit Testing

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. Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests. The first step, after you’ve created a Java project, is to add the Junit library to your Eclipse. Do this by selecting Add Libraries from the Build Path menu option from the popup menu that appears when you right click over your projectas shown below:

  2. Software Design– Unit Testing SIMPLE PRIMER ON Junit Select Junit from the Add Library window that appears and click Next.

  3. Software Design– Unit Testing SIMPLE PRIMER ON Junit Select Junit4 from the Junit library version pulldown that appears and click Finish.

  4. Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit should now appear in your package window.

  5. Software Design– Unit Testing SIMPLE PRIMER ON Junit You must code your test so that it checks to see the code you are testing operates properly. Otherwise it fails. When you determine the code fails, call the fail() routine so that Junit is informed of the failure. Observe the following simple test. public void testQuicksortDoubleArray() { double[] a = {10,2,3,4,5,6,7,8,9}; if (!InOrder(a)) fail(); } It will fail, because the array a is not in order. My mistake was not calling quicksort, but I will leave that to you to code.

  6. Software Design– Unit Testing SIMPLE PRIMER ON Junit To execute a Junit test, right click over the test file and select Run As from the popup menu and Junit Test from the sub menu.

  7. Software Design– Unit Testing SIMPLE PRIMER ON Junit If the test fails, the Junit window will turn red and you will see something similar to the following screen shot:

  8. Software Design– Unit Testing SIMPLE PRIMER ON Junit If the test passes, the Junit window will turn green and you will see something similar to the following screen shot:

More Related