# \`invoke\` for non-conforming types

**URL:** https://discourse.julialang.org/t/invoke-for-non-conforming-types/90720
**Category:** General Usage
**Tags:** metaprogramming
**Created:** [November 23, 2022, 4:32pm UTC](https://discourse.julialang.org/t/invoke-for-non-conforming-types/90720 "2022-11-23T16:32:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![erik-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik-f/32/18638_2.png) [@erik-f](https://discourse.julialang.org/u/erik-f)
#### Post date: [November 23, 2022, 4:32pm UTC](https://discourse.julialang.org/t/invoke-for-non-conforming-types/90720/1 "2022-11-23T16:32:32Z")

</div>

Is there a way to invoke a function

```julia
f1(::A) = nothing

```

with an argument that is not of the type `A`?  
So basically

```julia
invoke(f1, Tuple{A}, a)

```

where `a` is not of the type `A`.

As for the context: For advanced testing, I want to pass a mock object, whose behavior I specifically designed for this test, to a function that is supposed to take an argument of the non-mocked type.  
For example, I want to test the function

```julia
f2(a::A) = do_something_with(a)

```

like this

```julia
mock_a = Val(:mock_a)
do_something_with(a::Val{:mock_a}) = predefined_behavior_for_this_test()
@test f2(a) == do_something_with(a)

```
