This release removes numerous deprecated APIs. We recommend to upgrade to ~> 2.5 first and resolve any deprecation warnings before updating to v3.
-
Extracted
Mockery.Macroto separate library. For compatibility with Mockery v2, update yourmix.exsdependencies:def deps do [ {:mockery_macro, "~> 1.0", runtime: false}, {:mockery, "~> 3.0", only: [:dev, :test]} ] end
and your
.formatter.exs:[ inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"], import_deps: [:mockery, :mockery_macro] ]
-
Mockery no longer relies on
Mix.env(). To enable Mockery in tests, update config in your project:# config/test.exs config :mockery, enable: true
-
Mockery.History(extended failure output for macros fromMockery.Assertions) is now enabled by default. To disable it, update config in your project:# config/test.exs config :mockery, history: false
-
Removed deprecated functions:
Mockery.of/2Mockery.new/2Mockery.History.enable_history/1Mockery.Assertions.assert_called/2Mockery.Assertions.assert_called/3Mockery.Assertions.assert_called/4Mockery.Assertions.refute_called/2Mockery.Assertions.refute_called/3Mockery.Assertions.refute_called/4
-
This release requires Elixir ~> 1.15
-
use Mockery.Macrowon't inject unnecessary code when:mockeryisn't enabled in config -
Added
:suppress_dialyzer_warningsoption touse Mockery.Macro, see documentation for details -
Added
Mockery.Assertions.assert_called!/3andMockery.Assertions.refute_called!/3- New macros produce improved failure output.
-
Deprecated
Mockery.Assertions.assert_called/2,Mockery.Assertions.assert_called/3,Mockery.Assertions.assert_called/4,Mockery.Assertions.refute_called/2,Mockery.Assertions.refute_called/3andMockery.Assertions.refute_called/4- Use
Mockery.Assertions.assert_called!/3andMockery.Assertions.refute_called!/3instead - Deprecation warnings include a suggested replacement showing the expected syntax (the suggestion is generated from the deprecated call). Note: the suggestion is best-effort and may not exactly match your current code — verify and adjust as needed.
- Use
-
Improved
Mockery.mock/3- Added typespecs.
- It will now raise immediately if the mocked function does not exist. Previously,
Mockery.Errorwas raised from the proxy module. - It will now raise immediately if a dynamic mock has an invalid arity. Previously,
Mockery.Errorwas raised from the proxy module.
- Fix: Deprecation warning for mockable/2 was crashing for Elixir < 1.14
-
Deprecated
Mockery.of/2function.- Tuple calls used by this function won't be officially supported in Mockery v3.
Users should migrate to the macro-based alternative in
Mockery.Macro.
- Tuple calls used by this function won't be officially supported in Mockery v3.
Users should migrate to the macro-based alternative in
-
Mockery.Macro.mockable/2based onMix.env/0is deprecated.- Set
config :mockery, enable: trueinconfig/test.exsand recompile your project.
- Set
-
Added
Mockery.Macro.defmock/2andMockery.Macro.defmock/3macros -
Added macros and functions from
Mockery.Assertionstolocals_without_parensin.formatter.exs
- Fixed warnings (Elixir 1.18)
-
Added
use Mockery.Macroto solve new Elixir warnings- Replace
import Mockery.Macrobyuse Mockery.Macro
- Replace
- Added missing () to fix warnings
- Fixed issue preventing module attributes to be used in assert_called macros #34
- Allowed multiple mocks when using pipe operator or nested calls #27
- Deprecated
Mockery.History.enable_history/1in favor ofMockery.History.enable_history/0andMockery.History.disable_history/0
- Added
Mockery.Macro.mockable/2macro as alternative way to prepare module for mocking - Deprecated
Mockery.new/2
- Added
Mockery.new/2 - Fixed typo in error message #21
- Removed support for Elixir 1.1 and 1.2
- Fixed
Mockery.of/2typespecs
- When Mix is missing,
Mockery.of/2assumes that env is:prod
-
Removed
Mockery.Heritage- Global mocks will be handled without macros by pure elixir modules.
- Some new restrictions have been added for global mock modules (see global mock section in README)
-
Changed
Mockery.mock/3when value is function (dynamic mock)[function_name: arity]syntax remains unchanged:function_namesyntax will raise error
-
Changed
Mockery.of/2output- run
mix compile --forcewhen upgrading from Mockery 1.x.x
- run
Mockery.mock/2andMockery.mock/3are now chainable
- Minor format fix in
Mockery.Historyfailure messages
- Added string version for
Mockery.of/2(now recommended) - Fixed mocking of erlang modules
- Introduced
Mockery.History
-
More descriptive errors (when args are not list) for:
Mockery.Assertions.assert_called/3Mockery.Assertions.refute_called/3Mockery.Assertions.assert_called/4Mockery.Assertions.refute_called/4
-
Removed unnecessary
Elixir.namespace from module names in error messages
- Added
Mockery.mock/2(Mockery.mock/3value defaults to:mocked) - Added
Mockery.Assertions.assert_called/4macro - Added
Mockery.Assertions.refute_called/4macro
- Fixed issue when mocking with
nilorfalse
- Added
use Mockeryfor importing bothMockeryandMockery.Assertions - Added
Mockery.Assertions.refute_called/2andMockery.Assertions.refute_called/3 - Loosen elixir version requirement from
~> 1.3to~> 1.1