Successfully reported this slideshow.
Your SlideShare is downloading. ×

Take Control of your Integration Testing with TestContainers

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 21 Ad

Take Control of your Integration Testing with TestContainers

Download to read offline

Slides from my demonstration titled "Take Control of your Integration Testing with TestContainers". Demonstrates using TestContainers for RDBMS and test driving S3 API with localstack.

Slides from my demonstration titled "Take Control of your Integration Testing with TestContainers". Demonstrates using TestContainers for RDBMS and test driving S3 API with localstack.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Take Control of your Integration Testing with TestContainers (20)

Advertisement

More from Naresha K (20)

Recently uploaded (20)

Advertisement

Take Control of your Integration Testing with TestContainers

  1. 1. Take Control of your Integration Testing with TestContainers Naresha K @naresha_k https://blog.nareshak.com/
  2. 2. About me Developer, Architect & Tech Excellence Coach Founder & Organiser Bangalore Groovy User Group
  3. 3. Integration Testing?
  4. 4. Story #1
  5. 5. @Transactional class ConferenceService { def getConferencesInCities(List<String> cities) { Conference.where { city in cities }.list() } }
  6. 6. select this_.id as id1_0_0_, this_.version as version2_0_0_, this_.name as name3_0_0_, this_.city as city4_0_0_ from conference this_ where this_.city in ()
  7. 7. hibernate: cache: queries: false use_second_level_cache: false use_query_cache: false dataSource: pooled: true jmxExport: true driverClassName: org.h2.Driver username: sa password: '' logSql: true environments: development: dataSource: dbCreate: create-drop url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE test: dataSource: dbCreate: update url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE Application.yml (Test with H2)
  8. 8. dataSource: pooled: true jmxExport: true driverClassName: com.mysql.jdbc.Driver username: root password: secret logSql: true environments: development: dataSource: dbCreate: create-drop url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE test: dataSource: dbCreate: update url: jdbc:mysql://localhost:3306/testapp Application.yml (Test with MySQL)
  9. 9. testCompile platform('org.testcontainers:testcontainers-bom:1.12.5') testCompile 'org.testcontainers:spock' testCompile 'org.testcontainers:mysql' build.gradle
  10. 10. dataSource: pooled: true jmxExport: true driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver logSql: true environments: test: dataSource: dbCreate: update url: jdbc:tc:mysql:8://somehostname:someport/databasename Application.yml (Test with TestContainers)
  11. 11. @Integration @Rollback @Testcontainers class ConferenceTestContainerSpec extends Specification { @Shared MySQLContainer mySQLContainer = new MySQLContainer() .withDatabaseName("testapp") .withUsername("user") .withPassword("secret") ConferenceService conferenceService void "should return empty list"() { // test code } }
  12. 12. @Integration @Rollback @Testcontainers class ConferenceTestContainerSpec extends Specification { @Shared MySQLContainer mySQLContainer = new MySQLContainer() .withDatabaseName("testapp") .withUsername("user") .withPassword("secret") ConferenceService conferenceService void "should return empty list"() { // test code } } dataSource: driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver environments: test: dataSource: dbCreate: update url: jdbc:tc:mysql:8://somehostname:someport/databasename
  13. 13. Story #2
  14. 14. testCompile platform('org.testcontainers:testcontainers-bom:1.12.5') testCompile 'org.testcontainers:spock' testCompile 'org.testcontainers:mysql' testCompile "org.testcontainers:localstack" build.gradle
  15. 15. References https://github.com/naresha/agileindia2020testcontainersdemo https://www.testcontainers.org/
  16. 16. Thank You

×