Skip to content

iiroki/samples-testcontainers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Samples: Testcontainers

.NET Test Node Test

Testcontainers is an open source framework for running test dependencies as Docker containers.

The repository contains few samples on how to get started with Testcontainers with various languages.

Tools

The samples in the repository depend on the following tools:

  • Docker (required by Testcontainers)
  • Language-specific SDKs (see "Languages" below)

Languages

.NET

Version: .NET 8

.NET samples are located under dotnet/.

Structure

The sample .NET solution consist of three projects:

Only test projects have references to the tested project, not the other way around!

Commands

  • Run all tests from the solution:

    dotnet test
  • Run tests from a specific project:

    dotnet test <project_name>

Notes

  • The samples utilize InternalsVisibleToAttribute to expose internal objects to the test projects, see Samples.Testcontainers.csproj for the usage.

Node/TypeScript

Version: Node 20

Node samples are located under node/.

Structure

The Node project contains a simple Postgres example with Testcontainers.

Commands

Run all tests:

npm test

CI

The repository also demonstrates how to use Testcontainers in CI pipelines with GitHub Actions.

Integrating Testcontainers to CI pipelines is as almost as easy it can get, since the tests can just be executed with the chosen language's standard test commands without any extra configuration!

The GitHub Actions CI pipelines are located under .github/workflows:

  • dotnet-test.yml: .NET CI pipeline
    • Runs NUnit and xUnit tests separately and then together at the same time.
  • node-test.yml: Node CI pipeline
    • Runs tests with Jest.

About

Testcontainers samples with various languages.

Topics

Resources

License

Stars

Watchers

Forks