Slide 1

Slide 1 text

Oleg Nenashev, WireMock Inc

Slide 2

Slide 2 text

2

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Integration testing? 4 ● Multiple technology stacks and toolchains ● Many teams involved ● Sacred knowledge ● [Almost] always too late

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

7

Slide 8

Slide 8 text

Embedded Story 8 bit.ly/cpp_zurich_testcontainers_wiremock Slides are public!

Slide 9

Slide 9 text

> whoami @oleg_nenashev oleg-nenashev Dr. Nenashev / Mr. Jenkins Developer tools hacker Community builder & DevRel consultant #RussiansAgainstPutin #StandWithUkraine

Slide 10

Slide 10 text

Truly Russian C/C++ // my first project 10 tundrasolutions.ca/products/neftemer

Slide 11

Slide 11 text

@oleg_nenashev oleg-nenashev > whoami --c --cpp --embedded 11

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

13

Slide 14

Slide 14 text

14 wiremock.org/docs/stubbing IF (request_url) THEN (response) * * it gets MUCH more complex WireMock Config JSON: Client library response request Client App Mock API Server HTTP/2

Slide 15

Slide 15 text

WireMock in Java 15 wiremock.org/docs/stubbing

Slide 16

Slide 16 text

WireMock in Java 16 wiremock.org/docs/stubbing

Slide 17

Slide 17 text

17 WireMock 101 WireMock is a FOSS tool for building mock APIs Created in 2011 as a Java test library and CLI Available beyond Java, inc Rust or Golang You can can: ● Create stable development environments ● Isolate yourself from flakey 3rd parties ● Simulate APIs that don't exist yet wiremock.org

Slide 18

Slide 18 text

WireMock Features 18 wiremock.org/docs

Slide 19

Slide 19 text

WireMock Ecosystem & Features 19 wiremock.org/docs

Slide 20

Slide 20 text

WireMock Cloud by WireMock Inc. 20 ● WireMock creator is a co-founder of the Inc. ● WireMock Cloud - SaaS for end-to-end API mocking ● Private beta: K8s Edition for managed / on-premises ● API co-development wiremock.io

Slide 21

Slide 21 text

Breaking down JSON files Using WireMock Cloud app.wiremock.cloud 21

Slide 22

Slide 22 text

22 How about embedded? * we have customers in the space

Slide 23

Slide 23 text

IEEE Spectrum Research among members 23 https://spectrum.ieee.org/top-progra mming-languages-2021

Slide 24

Slide 24 text

24 jetbrains.com/lp/ devecosystem-2021/embedded/

Slide 25

Slide 25 text

25 Supported by WireMock and Testcontainers

Slide 26

Slide 26 text

26

Slide 27

Slide 27 text

27

Slide 28

Slide 28 text

github.com/testcontainers/testcontainers-c

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

30

Slide 31

Slide 31 text

31 Build Unit tests Publish Reports Integration tests Publish Reports WAS

Slide 32

Slide 32 text

Ways to do API integration testing 1. Testing against Production/Staging servers 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 3. Mocking at the API provider level (e.g. WireMock) 4. Mocking at the code level 32 Slow Fast Accu- rate Nope

Slide 33

Slide 33 text

Ways to do API integration testing 1. Testing against Production/Staging servers 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 3. Mocking at the API provider level (e.g. WireMock) 4. Mocking at the code level 33 Slow Fast Nope Accu- rate

Slide 34

Slide 34 text

34 Build Unit tests Publish Reports Integration tests Publish Reports NOW “Shift Left” Fast integrations tests are critical

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Why containers? ● Configuration Management ● Fast provisioning ● Clean environments ● Disposability ● Clustering

Slide 37

Slide 37 text

Docker in Embedded Prototypes, Dev Tools Test Infrastructures, CI/CD Docker Swarm Cluster on Raspberry Pi

Slide 38

Slide 38 text

Even simulator is not always an option http://blogs.synopsys.com/breakingthethreelaws 2014/04/the-secret-ninja-fu-for-higher-performa e-prototype-operation/ HAPS S96 Guess the price… Your device prototype is here

Slide 39

Slide 39 text

Docker ● Popular container engine ● Developer-friendly ● Huge ecosystem ● DockerHub and Container Registries ● Docker Compose – multi-container apps ● Universal image format (OCI) https://www.docker.com/

Slide 40

Slide 40 text

40 https://testcontainers.com

Slide 41

Slide 41 text

41

Slide 42

Slide 42 text

Example - JUnit 5 42

Slide 43

Slide 43 text

43

Slide 44

Slide 44 text

Containers are not always slow! ● On-demand image build ● Caching Docker image builds ● Suspending containers between tests ● Graceful termination ○ github.com/testcontainers/moby-ryuk 44 testcontainers.org

Slide 45

Slide 45 text

45 SDKs testcontainers.org

Slide 46

Slide 46 text

Example - WireMock for Rust 46 docs.rs/wiremock/latest/wiremock LukeMathWalker/wiremock-rs Note: WireMock for Rust is maintained outside the WireMock GitHub organization

Slide 47

Slide 47 text

github.com/testcontainers/testcontainers-c

Slide 48

Slide 48 text

Testcontainers for C/C++ 48 Started by the WireMock Team in September 2023 We have Embedded/Automotive customers and users who need it Based on Testcontainers or Go WireMock module gh:testcontainers/testcontainers-c

Slide 49

Slide 49 text

Example - WireMock with C code 49 github.com/testcontainers/testcontain ers-c/tree/main/examples/wiremock ● Testcontainers C is an experimental project ● Feedback is welcome! ● See more examples in the repository: CppUnit, OpenSCADA, etc.

Slide 50

Slide 50 text

50 Supported by WireMock and Testcontainers

Slide 51

Slide 51 text

51 Supported by WireMock and Testcontainers C/C++ Shared Lib Interface

Slide 52

Slide 52 text

Under the Hood 52 Testcontainers for Go C Adapter in Golang go build -buildmode=c-shared https://pkg.go.dev/cmd/cgo cgo C Header add-ons Header Files Test Code Your Project Test Executable

Slide 53

Slide 53 text

Using Testcontainers in C/C++ projects ● Built with CMake ● Any CMake-compatible package manager ● FetchContent ● CPM.make Coming soon: Conan, vcpkg 53 github.com/cpm-cmake/CPM.cmake

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

APIs are essential for Integration Testing 55 GROWTH IN WEB APIS SINCE 2005 Over 90% of developers use APIs. Skyrocket growth of APIs JANUARY 2006 JANUARY 2008 JANUARY 2010 JANUARY 2012 JANUARY 2014 JANUARY 2016 JANUARY 2018 MONTH The growth over time of the Programmable Web API API directory to more than 22,000 entries 22000 20000 18000 16000 14000 12000 10000 8000 6000 4000 2000 0 TOTAL API COUNT Programmable Web * Gartner Hype Cycle for APIs, 2022

Slide 56

Slide 56 text

APIs

Slide 57

Slide 57 text

57 Source: https://medium.com/10-minutes-qa-story/api-testing-from-scratch-api-anatomy-f220856ce9b3

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Ways to do API integration testing 1. Testing against Production/Staging servers 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 3. Mocking at the API provider level (e.g. WireMock) 4. Mocking at the code level 59 Slow Fast Accu- rate Nope

Slide 60

Slide 60 text

60

Slide 61

Slide 61 text

61 WireMock has an official Testcontainers module! testcontainers.com/modules/wiremock

Slide 62

Slide 62 text

62

Slide 63

Slide 63 text

WireMock for Go Testcontainers Module REST API Client Go test integrations go.wiremock.org 63 github.com/wiremock/wiremock-testcontainers-go

Slide 64

Slide 64 text

Powered by Testcontainers for C/C++

Slide 65

Slide 65 text

65 Solutions page for C/C++: wiremock.org/docs/solutions/c_cpp Testcontainers module github.com/testcontainers/testcontainers-c /tree/main/modules/wiremock

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

Using WireMock with Testcontainers for C/C++ in Google Test github.com/oleg-nenashev/wiremock-googletest-demo

Slide 68

Slide 68 text

68 WireMock for Google Test / C++ github.com/testcontainers/te stcontainers-c/tree/main/de mo/google-test

Slide 69

Slide 69 text

And then a test! 69 github.com/testcontainers/testcontainers-c/tree/main/demo/google-test

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

WireMock Public Roadmap 71 github.com/orgs/wiremock/projects/4

Slide 72

Slide 72 text

Testcontainers for C/C++ ● Support for more features from Testcontainers for Go ● C++ adapter with classes ● Conan and Vcpkg distributions ● Doxygen & docs 72 gh:testcontainers/testcontainers-c

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

74

Slide 75

Slide 75 text

Takeaways 75 ● Shift left your integration testing ● Mocking APIs and services, reducing external dependencies, containers ● There are tools for that, including WireMock and Testcontainers ● C/C++ is no exception from the trends

Slide 76

Slide 76 text

76

Slide 77

Slide 77 text

We need your feedback! 77 github.com/testcontainers/testcontainers-c/ …/CONTRIBUTING.md

Slide 78

Slide 78 text

Get Started wiremock.org/docs/solutions/embedded 78

Slide 79

Slide 79 text

79

Slide 80

Slide 80 text

It’s [always] a great time to contribute! testcontainers/testcontainers-c/../CONTRIBUTING.md wiremock.org/participate testcontainers.org/contributing 80

Slide 81

Slide 81 text

Credits to ● All WireMock contributors ● WireMock Inc. Team ● All Testcontainers contributors and AtomicJar folks ● All FOSS contributors 81

Slide 82

Slide 82 text

THANK YOU wiremock.org/testcontainers slack.wiremock.org slack.testcontainers.com github.com/shelajev/testcontainers-wiremock-demo wiremock.io 🏢

Slide 83

Slide 83 text

THANK YOU Contacts: E-mail: [email protected] GitHub: oleg-nenashev Twitter: @oleg_nenashev QUESTIONS? 83