Parallel Tests
Take a look at the parallel testing of the application.
We'll cover the following...
As with the last chapter, the parallel version of our system can be adapted by just declaring a new property and reusing the same model, to see if any glaring concurrency issues can be found.
Let’s take a look at the below code and watch the property in action.
Code
The property "parallel stateful property"
has been highlighted in the following code.
defmodule Bookstore.MixProject do use Mix.Project def project do [ app: :bookstore, version: "0.1.0", elixir: "~> 1.6", elixirc_paths: elixirc_paths(Mix.env), start_permanent: Mix.env() == :prod, deps: deps(), escript: escript_config() ] end defp elixirc_paths(:test), do: ["lib","test/"] defp elixirc_paths(_), do: ["lib"] # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger], mod: {Bookstore.App, []}, env: [ pg: [ # Single quotes are important user: 'postgres', # replace with your own $USER password: '', database: 'bookstore_db', # as specified by bookstore_init.ex host: '127.0.0.1', port: 5432, ssl: false # not for tests! ] ] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ {:eql, "~> 0.1.2", manager: :rebar3}, {:pgsql, "~> 26.0"}, {:propcheck, "~> 1.1", only: [:test, :dev]} ] end defp escript_config do [main_module: Bookstore.Init, app: nil] end end
Parallel testing
Once again, there are few changes ...