Spring Repository Unit Testing
Tech-Today

Spring Repository Unit Testing



Slack Discussion

Repositories
Alright. Now that we have a set of repository classes. I believe it’s a good time to introduce unit testing. Remember, unit testing is different compared to integration testing. The unit testing deals with a module like category while integration deals with a set of modules like the catalog. For example, an order module interacting with the inventory module.

Before we start creating our tests, I would like to check the following points:
To make the development and testing easier when switching database, we will be introducing a new maven profile.
[Open pom.xml] Notice that we created a new development-test profile which contains the h2 dependency. Whereas, the default profile development contains all the PostgreSQL specific dependencies as well as Liquibase.

Creating our very first test. As a default, we will have the contextLoads test.
[open TerawarehouseCatalogApplicationTests class]
What’s with the annotations?
[open application-integration.properties file]
Finally, it’s now time to present our very first repository unit test for the category.

[open CategoryRepositoryIntegrationTest]
Now, it’s time to execute our test. Note that you need maven to run it. Here’s the configuration.

[show screenshot of the maven build configuration]



Next, we will start creating our REST API. See you in our next video.

Ja ne.





- Database Initialization Using Script
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactThere are times when we want to use a SQL script to generate the schema and populate the database. Personally, I use...

- Database Initialization Using Code
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactThere are various ways in which we can initialize the database. Mostly for testing purposes I find setting hibernate.ddl-auto...

- Working With Spring Data Repositories
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactJust like what we did with the entities the same approach can be used when creating the repository classes. And that...

- Create A Restful Web Service In Spring
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactTo prepare the project from future development, we will be creating a multi-maven project layout. Unfortunately,...

- Catalog And Sellout Management System Using Spring
A catalog and sales order management system is commonly used by companies to manage their catalog and capture their sales data into a centralized database so that a real-time accurate report can be generated instantly. This application can trigger notification...



Tech-Today








.