# Testing local functions

**URL:** <https://discourse.julialang.org/t/testing-local-functions/29521>\
**Category:** General Usage\
**Created:** [October 5, 2019, 3:08pm UTC](https://discourse.julialang.org/t/testing-local-functions/29521 "2019-10-05T15:08:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxPauer](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MaxPauer](https://discourse.julialang.org/u/MaxPauer)\
**Post date:** [October 5, 2019, 3:08pm UTC](https://discourse.julialang.org/t/testing-local-functions/29521/1 "2019-10-05T15:08:54Z")

</div>

I recently learned about using let-blocks for encapsulation.  
Is there any good way to test functions within let-blocks apart from making them global?

```julia
function only_global_for_testing end
function actually_needed_in_interface end

let local_num = 5
  global only_global_for_testing() = local_num * 2 # meh...
  global actually_needed_in_interface() = only_global_for_testing() * 2 # ok
end

# in my testfile

# ...
@test only_global_for_testing() == 10
@test actually_needed_in_interface() == 20
# ...

```

Is there any standard-Julia-way of testing those local functions that I’d rather not have in my interface?  
Or is the rule to go: If it is important enough to be tested on its own, it is probably important enough for the interface?
