Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

Share

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.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

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
  • powerirs

    Oct. 20, 2020

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.

Views

Total views

193

On Slideshare

0

From embeds

0

Number of embeds

40

Actions

Downloads

2

Shares

0

Comments

0

Likes

1

×