All Projects → UrbanOS-Public → divo

UrbanOS-Public / divo

Licence: Apache-2.0 license
Docker Integration and Validation Orchestrator for Elixir with Mix

Programming Languages

elixir
2628 projects
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to divo

Testrocket
Super simple Ruby testing library
Stars: ✭ 229 (+638.71%)
Mutual labels:  testing-tools
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+9461.29%)
Mutual labels:  testing-tools
phptt
phptt a.k.a php test tools
Stars: ✭ 15 (-51.61%)
Mutual labels:  testing-tools
Swaks
Swaks - Swiss Army Knife for SMTP
Stars: ✭ 239 (+670.97%)
Mutual labels:  testing-tools
Diffx
Pretty diffs for scala case classes
Stars: ✭ 250 (+706.45%)
Mutual labels:  testing-tools
kentan
A modular test data generator for TypeScript
Stars: ✭ 38 (+22.58%)
Mutual labels:  testing-tools
Goreplay
As your application grows, the effort required to test it also grows exponentially. GoReplay offers you the simple idea of reusing your existing traffic for testing, which makes it incredibly powerful. Our state of art technique allows you to analyze and record your application traffic without affecting it. This eliminates the risks that come with putting a third party component in the critical path.
Stars: ✭ 14,981 (+48225.81%)
Mutual labels:  testing-tools
rtl-simple-queries
Simple wrapper queries for @testing-library/react
Stars: ✭ 20 (-35.48%)
Mutual labels:  testing-tools
Database cleaner
Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing.
Stars: ✭ 2,750 (+8770.97%)
Mutual labels:  testing-tools
allure-nunit
Archived - Allure adapter for NUnit framework.
Stars: ✭ 45 (+45.16%)
Mutual labels:  testing-tools
Objectexporter
Object Exporter lets you export out an object while debugging in Visual Studio, the object can be serialized in either C#, JSON or XML.
Stars: ✭ 240 (+674.19%)
Mutual labels:  testing-tools
Kotlin Compile Testing
A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Stars: ✭ 245 (+690.32%)
Mutual labels:  testing-tools
fluttertest
Custom flutter testing CLI tool for individual test runs and group testing
Stars: ✭ 15 (-51.61%)
Mutual labels:  testing-tools
Mockito Scala
Mockito for Scala language
Stars: ✭ 231 (+645.16%)
Mutual labels:  testing-tools
bibop
Utility for testing command-line tools, daemons, and packages
Stars: ✭ 17 (-45.16%)
Mutual labels:  testing-tools
Htmltestrunner
A Test Runner in python, for Human Readable HTML Reports
Stars: ✭ 228 (+635.48%)
Mutual labels:  testing-tools
Pywinauto
Windows GUI Automation with Python (based on text properties)
Stars: ✭ 3,175 (+10141.94%)
Mutual labels:  testing-tools
graphql-query-generator
Generates queries from the GraphQL endpoint via schema introspection.
Stars: ✭ 49 (+58.06%)
Mutual labels:  testing-tools
go-smtp-mock
SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.
Stars: ✭ 76 (+145.16%)
Mutual labels:  testing-tools
vision-ui
视觉UI分析工具
Stars: ✭ 165 (+432.26%)
Mutual labels:  testing-tools

Hex.pm Version

Getting Started

Easily run Elixir integration tests with docker-compose. Provide Divo with docker-compose configuration, add use Divo to your integration tests, and run with mix test.integration.

Installation

The package can be installed by adding divo to your list of dependencies in mix.exs:

def deps() do
  [
    {:divo, "~> 1.3.1", only: [:dev, :integration]}
  ]
end

The docs can be found at https://hexdocs.pm/divo. New versions are published with actions upon github release.

Configuration

Docker

Define services in your mix configuration file to define the dockerized service(s) you want to run as a dependency of your Elixir app. Define divo config in one of the following three ways:

Method 1 - Compose file

In your config, include the path to the yaml or json-formatted compose file

#config/config.exs
config :myapp,
  divo: "test/support/docker-compose.yaml,
  divo_wait: [dwell: 700, max_tries: 50]
#test/support/docker-compose.yaml
version: '3'
services:
  redis:
    image: redis
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "PING"]
      interval: 5s
      timeout: 10s
      retries: 3

Method 2 - Pre-existing module

In your mix file, include the additional dependency

#mix.exs
def deps() do
  [
    {:divo, "~> 1.3.1", only: [:dev, :integration]},
    {:divo_redis, "~> 0.1.0", only: [:dev, :integration]}
  ]

And in your config, include the imported dependency module(s) as a list of tuples along with any environment variables the stack takes as a keyword list

#config/config.exs
config :myapp,
  divo: [
    {DivoRedis, [initial_key: "myapp:secret"]}
  ],
  divo_wait: [dwell: 700, max_tries: 50]
Known Modules:

Method 3 - Elixir map

#config/config.exs
config :myapp,
  divo: %{
    version: "3",
    services: %{
      redis: %{
        image: "redis:latest",
        ports: [
          "6379:6379"
        ],
        healthcheck: %{
          test: ["CMD", "redis-cli", "PING"],
          interval: "5s",
          timeout: "10s",
          retries: 3
        }
      }
    }
  },
  divo_wait: [dwell: 700, max_tries: 50]

Split Unit and Integration Tests

You will need to move any existing unit tests into a sub directory. We recommend the following structure:

myapp
  └── test
      ├── integration
      │   ├── myapp_test.exs
      │   └── test_helper.exs
      └── unit
          ├── module_a_test.exs
          ├── module_b_test.exs
          └── test_helper.exs

NOTE: test_helper.exs must be included in the root of both integration and unit tests.

Test Paths

Add this to your mix.exs to ensure that your unit and integration tests run in isolation from each other.

#mix.exs

def project do
  [
    # ...
    test_paths: test_paths(Mix.env())
  ]
end

# ...

defp test_paths(:integration), do: ["test/integration"]
defp test_paths(_), do: ["test/unit"]

Use Divo in an Integration Test

In each integration module add:

use Divo

Divo will then take care of running docker-compose up before running your tests and then run docker-compose down after they've completed.

NOTE: Divo will start and stop docker-compose for every integration test module, unless the "DIVO_DOWN" environment variable is set to "DISABLED".

Example Integration Test Module using redix:

defmodule MyAppTest do
  use ExUnit.Case
  use Divo

  test "persisting and reading from redis" do
    {:ok, conn} = Redix.start_link(host: "localhost", port: 6379)
    Redix.command(conn, ["SET", "mykey", "foo"])
    {:ok, result} = Redix.command(conn, ["GET", "mykey"])
    assert result === "foo"
  end
end

Use Divo for the entire test suite

In your integration or test suite's test_helper.exs file add Divo.Suite.start() before ExUnit.start() Example:

Divo.Suite.start()
...
ExUnit.start()

This will make Divo stand up dockers that last the entire run of the test suite (or just a few modules or tests if you specified them in your mix test.integration command). It will wire itself up to tear down the dockers if in cases where the tests fail to compile.

Ideally, you will want to NOT have use Divo in your tests. However, if you leave use Divo in for all of the tests, and still add the start to your test_helper.exs the tests will still run as expected, with an additional docker start and stop wrapped around the whole run.

The Divo.Suite.start function takes all of the options that use Divo does plus a few extras for controlling where the final docker cleanup occurs:

  • auto_cleanup? - whether or not to cleanup dockers on program exit. Defaults to true

Whether or not you choose to let it cleanup after itself, Divo.Suite.start will return a zero-arity cleanup hook that you can call when you want to explicitly cleanup the dockers.

Divo.Suite.start()
|> on_exit()

Running Integration Tests

Integration tests are executed by running:

mix test.integration

License

Released under Apache 2 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].