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.
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:
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.
- Right-click the web folder and select Execute Maven Goal
- In the dialog that opens, enter clean install -DskipTests -X as the maven command to be executed.
- 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.
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!
- Right-click the web folder and click Build and Run Tests.
- 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.
- 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.