Skip to content

JuliaTesting/SimpleMock.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleMock Docs CI

Notice: kind of broken

This package is broken in some cases on Julia 1.6 and newer, for unknown reasons. Use at your own risk!


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.