Skip to Content

This blog post is part 2 of a series of blogs on how to develop a Java application in SAP Web IDE Full-Stack.

Part 2 describes how to Build and Test your Java application.

Before reading this blog please make sure that you have read the first part of this series.

Part 3 of the series describes how to Run and Debug the application, as well as our new Hot Deployment feature.

 

Build

Right-click the web folder and click Build.

 

The SAP Web IDE console automatically starts the Maven build process for our web Java Module.
SAP Web IDE provides 2 indications once the build is complete:

Console log:

Notification at the upper-right corner of the screen:

A new folder called target is created under our web Java module.
It contains our build result packaged as a WAR file.

SAP Web IDE Full-Stack also supports building the Java module using custom Maven goals.
You can execute any build lifecycle phase or even a granular task by entering Maven commands without the mvn prefix in the command line.

Note that the input is not validated. If you enter an invalid command, the build will fail.

Let’s try this out.

  1. Right-click the web folder and select Execute Maven Goal
  2. In the dialog that opens, enter clean install -DskipTests -X as the maven command to be executed.
  3. Click Execute. The SAP Web IDE console is opened again showing extensive information when compared to the normal build because we used the -X parameter.

 

Test

Now that we successfully built our web Java Module, let’s run some unit tests.
The Simple Web Application template is generated with a Junit test Java class called: TestsUnitHelloServlet.java

Let’s run it!

  1. Right-click the web folder and click Build and Run Tests.
  2. This triggers a Maven build of the module including tests.A new right-side pane called Test Results is opened, displaying the JUnit test result.
    After opening the HelloServlet.java calss, we can verify which lines are being covered by the test and which are not.
  1. To clean up the marking in the Java file, click Refresh test results.

 

In our next part of the series, we will Run and Debug our web Java Module.

 

To report this post you need to login first.

1 Comment

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

  1. Kıvanç Aktaş

    Firstly, thanks for the nice and informative blog Mr. Shostak.

    I just want to add additional information for beginners in Cloud Foundry like me.

    If someone gets error like below :

    2:25:29 PM (Builder) Could not start the build of ‘/mtaproj/web’ because the Cloud Foundry settings are not configured for your project.
     Go to Project Settings > Cloud Foundry, select your space, and click Install Builder.

    2:25:29 PM (Builder) Build of /mtaproj/web failed.

     

    Here solution steps :

    • Go to your trial account page : account.hanatrial.ondemand.com
    • Click Cloud Foundry Trial and activate your Cloud Foundry space.
    • Open SAP Web IDE Full-Stack->Tools->Preferences->Cloud Foundry
    • Select your Cloud Foundry space according to your region.
    • Click Install Builder (Wait several seconds it can take about 1 min.)
    • Click Save button on the left bottom corner.
    • Than finally you can continue from Build section from this blog.

    Thanks again for this nice blog.

    (0) 

Leave a Reply