SimpleMock.jl

A basic mocking module
Author JuliaTesting
Popularity
16 Stars
Updated Last
2 Years Ago
Started In
September 2019

SimpleMock Docs Build Status

A basic mocking module, inspired by Python's unittest.mock and implemented with Cassette.

using SimpleMock

f(x) = x + 1
mock(+) do plus
    @assert plus isa Mock
    @assert f(0) != 1  # The call to + is mocked.
    @assert called_once_with(plus, 0, 1)
end

mock((+, Float64, Float64) => Mock((a, b) -> 2a + 2b)) do plus
    @assert 1 + 1 == 2
    @assert 2.0 + 2.0 == 8
    @assert called_once_with(plus, 2.0, 2.0)
end

See the documentation for more details and examples.

Required Packages

Used By Packages

No packages found.