Presentation is loading. Please wait.

Presentation is loading. Please wait.

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,

Similar presentations


Presentation on theme: "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,"— 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 project as 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}; double[] a = {10,2,3,4,5,6,7,8,9}; if (!InOrder(a)) if (!InOrder(a)) fail(); 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:


Download ppt "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,"

Similar presentations


Ads by Google