Skip to Content
JUnit is an unit testing framework for Java. The philosophy behind this testing framework is to make coding and testing move hand in hand. Lets apply this philosophy of testing and coding side by side to the (object oriented version of) Hello World program by creating a test case for it in SAP NetWeaver Developer Studio.

Steps:

1. Select File > New > Project.

image

2. Select Java Project from the wizard and click Next.

image

3. Enter the following details and click Next.

image

4. Under Java Settings go to the Library tab and click on Add External JARs...

5. Add &ltJDT_HOME>SAPeclipsepluginsorg.junit.X.X.Xjunit.jar to the classpath.

image

6. Click Finish to create the project.

7. Click OK if a dialog requesting to switch to Java Perspective appears.

8. Now go to context menu of the project and Select New > Class to create a new Java class.

image

9. Add the following details for the class.

image
10. Type in the following code for the class.

11. Now select New > JUnit Test Case from context menu of the Project.

image

12. Enter the following details and Click Next.

image

13. Now select formMessage() method under Available Methods and click Finish.

image

14. Write the following code for the HelloWorldTest class.

15. Select form context menu of the project Run > JUnit Test.

image

16. Congrats, the green bar indicates that the test is succesful. (If the test case fails red bar and error messages are displayed)

image

17. Select form context menu of the project Run > Java Application to Run the Hello World Program.

image

18. The string “Hello World” is printed to the console.

image

This finishes the JUnit based Hello World program in SAP NetWeaver Developer Studio.

Other related SDN Weblogs.
1. Creating  testing  environment while coding for java programs
2. Using Junit in Web Application Server

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply