项目作者: JuliaTesting

项目描述 :
A basic mocking module
高级语言: Julia
项目地址: git://github.com/JuliaTesting/SimpleMock.jl.git
创建时间: 2019-09-08T05:07:05Z
项目社区:https://github.com/JuliaTesting/SimpleMock.jl

开源协议:MIT License

下载


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.

  1. using SimpleMock
  2. f(x) = x + 1
  3. mock(+) do plus
  4. @assert plus isa Mock
  5. @assert f(0) != 1 # The call to + is mocked.
  6. @assert called_once_with(plus, 0, 1)
  7. end
  8. mock((+, Float64, Float64) => Mock((a, b) -> 2a + 2b)) do plus
  9. @assert 1 + 1 == 2
  10. @assert 2.0 + 2.0 == 8
  11. @assert called_once_with(plus, 2.0, 2.0)
  12. end

See the documentation for more details and examples.