Comments (11)
Generally I don't prefer using H2 because it may give you wrong impression how it will behave with real database. Using real database with docker will give you close impression of database
from generator-springboot.
Hi, I can work on it.
I believe we want to test repo IT using DataJpaTest, Is there any default convention you want to configure like
- Using H2 or HSQL db
from generator-springboot.
Hi @sagar-rout ,
Since we already have H2 in the dependency, spring boot will automatically pick it up.
If you got struck anywhere, please ping us we will help you. Assigned ticket to you
from generator-springboot.
yeah, I know that spring will pick up H2 from classpath and do you want me to turn off this setting by using
@ AutoConfigureTestDatabase
from generator-springboot.
Ideally, if we want to test only repository layer then we need to connect to real database (postgres, MySQL, etc...)which we are using in our application. But here as we have integration tests that connects to real database then it will become duplicate effort. Hence for Repository tests we can go with H2.
@sivaprasadreddy , please provide your thoughts.
from generator-springboot.
I would definitely prefer to use the same type of database for testing which we use for production.
We don't need to write tests for the repository methods provided by framework itself(findAll(), findById(), etc).
If there are integration tests that covers your custom methods then we may not have to write repository test as it is going to be redundant.
from generator-springboot.
so, I would say having a skeleton for repo would be more than enough and I can mark the H2 disable which may force the user to use the db.
from generator-springboot.
Currently H2 config/code is added by default. I think we can make it one of the options like MySQL, PostgreSQL, etc and add H2 related code only when H2 is selected. With Spring Boot version 3.1.0+ support for Testcontainers, we hardly need H2.
from generator-springboot.
Hi @sagar-rout , when you are working on PR, can you please move the ApplicationIntegrationTest to repository layer like in this PR and rename it.
As it becomes slice testing it will not load beans from other layer thus reducing the executing time. This also sets up infrastructure for @DataJpaTest
cc : @sivaprasadreddy
from generator-springboot.
Hi @rajadilipkolli @sagar-rout
I think we have mixed up 2 different things in this issue.
One is generating tests for Jpa Repositories and two is adding schema validation test.
Regarding schema validation test: We already have ApplicationIntegrationTest which is an integration test that will verify whether the application can be started properly or not provided the required services via Testcontainers. It is also configured to perform schema validation as well. So schema validation is already taken care of.
Regarding generation of tests for Jpa Repository: Currently we are not adding any custom methods to the generated JpaRepositories. I believe we shouldn't need to test the methods inherited from framework like save(), findAll() etc. So, generating tests might not be useful.
I will create a separate issue to make H2 database as one of the option instead of adding it by default.
So, I am closing this issue for now. If you disagree, please feel free to re-open this issue. We can discuss further.
from generator-springboot.
Hi @sivaprasadreddy , I will work on the PR, to provide infra for @DataJPATest
, then we can decide if we should reopen this issue.
Regarding Schema validation Test, we are loading the whole application context, which is counterproductive, as the same can be achieved with @DataJpaTest
quickly. So, want to pursue it by combining both.
Background to this issue, I have an application which uses graphql, verifies schema and perform some initial steps as a result the time taken to execute SchemaValidation test is up to 30sec, when I have modified the same to use @DataJpaTest
it was completed in 10 sec.
from generator-springboot.
Related Issues (20)
- Skip adding PagedResult.java when liquibase or flyway migrationversion is greater than 2
- Action Required: Fix Renovate Configuration
- V1.16.0
- Feature request: Give option to generate properties in yaml format HOT 1
- support spring cloud AWS 2.3 and deprecate 2.2 HOT 1
- sonar.properties is reflecting values of gradle build instead of maven build HOT 1
- Upgrade the ELK Stack to 8.x version in docker-compose HOT 1
- Enable Github's Discussion HOT 1
- Improper db table names when using CamelCase variable name HOT 1
- Confusion with pageNumber on Pagination HOT 4
- Support for other Liquibase migration formats (yaml, sql) HOT 5
- Remove unused property values in Application.java
- Automate npm release process
- Add support for restclients HOT 2
- Add support for spring boot 3 observability
- Adds support for grafana loki stack
- DTO HOT 3
- Code Clean up for 0.1.3 version HOT 2
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator-springboot.