Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

Commit

Permalink
fix: error when no tests [Closes parroty#43]
Browse files Browse the repository at this point in the history
Having just this test suite:

defmodule SansConfTest do
  use ExUnit.Case
  use ExCheck

  # test "greets the world" do
  #   assert SansConf.hello() == :world
  # end
end

Would cause:

** (EXIT from #PID<0.92.0>) exited in: GenServer.stop(#PID<0.262.0>, :normal, 30000)
    ** (EXIT) exited in: :sys.terminate(#PID<0.262.0>, :normal, :infinity)
        ** (EXIT) an exception was raised:
            ** (KeyError) key :test not found in: %{}
                (excheck) lib/excheck/formatter.ex:65: ExCheck.Formatter.update_tests_counter/1
  • Loading branch information
devstopfix committed Aug 7, 2019
2 parents b2a083b + d2e26c8 commit cf551a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ elixir:
- 1.8
- 1.7
- 1.6
- 1.5
# - 1.5

before_script:
- if [[ "$TRAVIS_ELIXIR_VERSION" =~ "1.9" ]]; then mix format mix.exs "{config,lib,test}/**/*.{ex,exs}" --check-formatted; fi
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ First add ExCheck and [triq][triq] to your project's dependencies in `mix.exs`.
```Elixir
defp deps do
[
{:excheck, git: "https://github.com/devstopfix/excheck.git", tag: "0.7.0", only: :test},
{:excheck, git: "https://github.com/devstopfix/excheck.git", tag: "0.7.1", only: :test},
{:triq, "~> 1.2"}
]
end
Expand All @@ -23,9 +23,9 @@ You need to have erlang-eunit installed in order to build triq.
and add the following to test_helper.exs:

```Elixir
ExCheck.start
ExCheck.start()
# ... other helper functions
ExUnit.start
ExUnit.start()
```

### Configuration
Expand Down Expand Up @@ -154,6 +154,16 @@ The following generators defined in :triq are imported through "use ExCheck" sta
- It's a trial implementation, and has limited functionalities yet.
- Files in test folder contains some more property examples.

Issues closed:

* [43](https://github.com/parroty/excheck/issues/43)

### Credits

- [parroty](https://github.com/parroty) for authoring this library
- [triq developers](https://gitlab.com/triq/triq/-/project_members) for the core library
- [luc-tielen](https://github.com/luc-tielen) for bug fixes


[triq]: https://hex.pm/packages/triq
[elixirv]: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/pages/Compatibility%20and%20Deprecations.md
4 changes: 3 additions & 1 deletion lib/excheck/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ defmodule ExCheck.Formatter do
total_tests
end

defp update_tests_counter(tests_counter) when is_map(tests_counter) do
defp update_tests_counter(%{test: _} = tests_counter) when is_map(tests_counter) do
total_tests = %{tests_counter | test: tests_counter.test + ExCheck.IOServer.total_tests()}
ExCheck.IOServer.reset_test_count()
total_tests
end

defp update_tests_counter(%{}), do: %{}
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule ExCheck.Mixfile do
name: "ExCheck",
source_url: "https://github.com/devstopfix/excheck",
homepage_url: "https://github.com/parroty/ExCheck.git",
version: "0.7.0",
version: "0.7.1",
elixir: "~> 1.5",
deps: deps(),
description: description(),
Expand Down

0 comments on commit cf551a7

Please sign in to comment.