Upgrade to Pro — share decks privately, control downloads, hide ads and more …

我覺得草莓尬肉粽不行: 從草莓肉粽了解整合測試的重要性

我覺得草莓尬肉粽不行: 從草莓肉粽了解整合測試的重要性

活動:LINE Developers Meetup 開發者小聚 #18 - TECH FRESH 畢業展
活動頁面:https://linegroup.kktix.cc/events/20230627-tech-fresh-gratudation
講者:Brian Kuo, TECH FRESH @ LINE TRAVEL

LINE Developers Taiwan

July 02, 2023
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Technology

Transcript

  1. ⾁粽 OK!草莓也 OK! ※ Source from ︓ • https://reurl.cc/RzXA3e •

    https://removal.ai/ • https://www.gomaji.com/blog/%E7%AB%AF%E5%8D%88%E8%82%89%E7%B2%BD/
  2. 01 02 03 04 05 Contents Background & Motivation Unit

    tests vs. Integration tests Difficulties in Integration tests Intro to Testcontainers A concrete example
  3. Integration tests Unit tests vs. Integration tests Database connection External

    API calls Isolation Mock / Stub Unit tests External Service Integration
  4. Latency, packet loss, unreliable network channels Network Issue Expected state

    or behavior doesn’t match between two ends Data Inconsistency Concurrent operation leads to unexpected behavior Race Condition Even though two modules may separately pass their own unit tests, they may still fail when combined altogether Integration tests might fail...
  5. Historic Implementations of Integration tests Pre-provisioned Infrastructure Setup Cost Test

    Pollution In-memory Database Service Challenges in maintaining an “Integration Testing Environment” Difficulties in Integration tests Feature Limitation Slow Feedback Cycle Testcontainers solves these issues! ※ Source from ︓ • https://testcontainers.com/guides/introducing-testcontainers/ • https://www.flaticon.com/
  6. Real Services Docker Containers Ensure consistency across different development stages

    • easy to setup and teardown • provide a clean and complete instance Intro to Testcontainers A testing library that supports integration tests with real services wrapped in Docker containers ※ Source from ︓ • https://testcontainers.com/guides/introducing-testcontainers/ Include external dependencies within our tests • database layer • stream processing • any docker images
  7. Workflow of Testcontainers • Before Tests: • Launch required services.

    E.g., databases, external dependencies. • During Tests: • Your tests will run using these containerized services. • After Tests: • destroying those started containers gracefully without interference. ※ Source from : • https://testcontainers.com/guides/introducing-testcontainers/
  8. Benefits from using Testcontainers • No pre-provisioned infra needed •

    No data conflict issues • Local test support • Support multiple languages, including .NET, Go, NodeJS, and Python ※ Source from : • https://testcontainers.com/guides/introducing-testcontainers/
  9. Here, we perform integration tests with Testcontainers using TypeScript &

    Jest A concrete example Utilize Testcontainers with lightweight API Containers being launched during test running