Skip to content

ma-hab/avoid-transactional-in-tests

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Don’t Use @Transactional in Tests

This is the sample code used for the article below, where I talk about the problems of using @Transactional in Spring Boot integration tests:

Installation

Database

You need to have PostgreSQL installed in your system.

Then configure the environment variables below:

  • DATABASE_HOST: localhost
  • DATABASE_NAME: avoid-transactional
  • DATABASE_USERNAME: postgres
  • DATABASE_PASSWORD: yourpassword

You can of course provide different values depending on your local database configuration.

I recommend you to create two databases, one for production and another for tests. So you can run the tests without interfering with manual production testing using a tool like cURL or Postman. You’ll need to change the DATABASE_NAME variable in-between.

Development

Be sure to have JDK and Maven installed in your system, and then execute the project by running:

mvn spring-boot:run

To run the tests:

mvn test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%