How to test repository?
See original GitHub issueHi!
I need to know how can I test my repository. For example:
class AdminRepositoryImpl : AdminRepository {
override fun create(builder: AdminParams): Int {
return transaction {
Admins.insert {
it[login] = builder.login
it[password] = builder.password
it[createdAt] = DateTime.now()
}[Admins.id].value
}
}
}
How can I test it? I use ktor + exposed, so I thought that “withTestApplication” will be work but it doesn’t .
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How to test Spring Data repositories? - Stack Overflow
To make it short - there's no way to unit test Spring Data JPA repositories reasonably for a simple reason: it's way to...
Read more >How to test services, endpoints, and repositories in Spring Boot
It is quite simple to test. We mock the repository and inject our mocks into UserService. Now when we run the test we'll...
Read more >Spring Boot JPA - Unit Test Repository - Tutorialspoint
Right Click on the file in eclipse and select Run a JUnit Test and verify the result. Repository Test Result. Previous Page Print...
Read more >How to Unit Test a Repository Implementation
I like to unit test every layer within my applications. Unit testing data access code can be a little tricky, firstly because they...
Read more >Controller, Service, and Repository Layer Unit Testing using ...
4. Tips for writing testable code · Strictly follow the SOLID principal · Use dependency injection properly. · Separate object creation and application...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Depending on your test/use case I use this test function:
Remove the “features” you don’t use, eg contracts,
suspend
, name etc. Usagei want to test the above mentioned insert operation, so i can i make sure, whether database is correctly inserted or not with test with the command, i gave, @Tapac @LookBad