Skip to main content

Chapter 1 : Backend API Development

Backend API Development

Build a Backend for your App.

Using development automation, build secure & scalable backend server with EasyManage API builder, use suitable database choice.

Data Modeling

Please refer to tutorial:

Testing - tests

  • tests UT Unit Tests, IT Integration Tests

Unit Tests

  • Testing Frameworks and Tools Used

    • JUnit
    • Mockito
  • Unit Tests generated

    • emapi project generates unit tests for -
      • Service Unit Test
        • e.g. emapi\lib\base-app\test\Product\ProductServiceUTest.java
      • Controller Unit Test
        • e.g. at emapi\app\dbrest\test\Product\ProductDataRestControllerUTest.java

Integration Tests

  • Testing Frameworks and Tools Used
    • JUnit
    • Mockito
      • Using @MockBean
info

Generated tests are based on this approach:

  • Integration testing with @MockBean in Spring Boot involves replacing a real bean in the application context with a mock object. This allows for isolating and testing specific components of an application in integration tests.
  • For integration tests focussing on integrating different layers of the application, with no mocking involved, below are provided:
  • Integration Tests generated

    • emapi project generates integration tests for -
      • Controller
        • e.g. emapi\app\dbrest\test\Product\ProductRestApiITest.java

Run Tests

Make sure properties are set,

  • <skipUTs>false</skipUTs>

  • <skipITs>false</skipITs>

  • To Run tests : Build project - verify

    • mvn clean verify

Surefire Report Aggregate

Generate Using command -

mvn surefire-report:report-only -Daggregate=true
  • Report Location
    • emapi\target\site\surefire-report.html

Run Tests: Report Location

  • View Report Surefire Report for unit tests

Surefire Report

Failsafe Report Aggregate

Generate Using command -

mvn surefire-report:failsafe-report-only -Daggregate=true
  • Report Location

    • emapi\target\site\failsafe-report.html
  • View Report Failsafe Report for integration tests

Failsafe Report