# How to add tests for an interactive package

**URL:** <https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349>\
**Category:** Tooling\
**Created:** [July 19, 2020, 7:50pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349 "2020-07-19T19:50:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [July 19, 2020, 7:50pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/1 "2020-07-19T19:50:33Z")

</div>

Hi all

I’ve been working on a small package, [FloatingTableView.jl](https://github.com/pdeffebach/FloatingTableView.jl), which adds easy support for using TableView.jl from the terminal.

I often find “grid”-based IDEs limiting because you can’t rearrange windows within your application as easy as you would if they were just normal winows. I also prefer Sublime text for editing. As a consequence I wrote this small package to make using TableView easier.

All it does is enact the screenshot in the [readme](https://github.com/JuliaComputing/TableView.jl) for TableView.jl,

```julia
function browse(df, kwargs...)
    w = Blink.Window()
    body!(w, showtable(df; kwargs...)) 
end

```

I would like to work on getting this registered. My question is, how should I design tests for this package? Currently I just call the function `browse` a few times, so the `runtests.jl` script really just tests to make sure there are no errors.

Any ideas on how to write tests for this? It doesnt have to be too complicated.

Thanks,

Peter

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [July 20, 2020, 2:00pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/2 "2020-07-20T14:00:49Z")

</div>

The most realistic low-effort solution is to just do

```julia
@test browse(args...) isa WebIO.Scope

```

which really doesn’t test anything except that your function doesn’t error.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [July 20, 2020, 2:43pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/3 "2020-07-20T14:43:57Z")

</div>

Often for interactive/GUI stuff you can narrow the actual interactive/GUI stuff into a small UI API (which may be internal),  
and then the logic of how to do that stuff seperately.  
Then you test how the logic interacts with the UI API.  
And you take a pass on automatic tests for the UI parts.

This can be done via Mocking.  
[https://github.com/invenia/Mocking.jl](https://github.com/invenia/Mocking.jl)  
or  
[https://github.com/christopher-dG/SimpleMock.jl](https://github.com/christopher-dG/SimpleMock.jl)  
handle replacing function calls with mocked out version of them.

On top of those (or other dependency injection) you could use something like  
[https://github.com/oxinabox/ExpectationStubs.jl](https://github.com/oxinabox/ExpectationStubs.jl)  
which helps simplify writing arrange-act-assert type tests

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [July 21, 2020, 6:51pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/4 "2020-07-21T18:51:37Z")

</div>

Thanks, I may go with this option since `mock`ing seems a bit overkill for this package, which is really just a glue package where I implement very few things myself.

To clarify, it would be a very big deal if `Blink` stopped being able to display `WebIO.Scope` objects, right? There is a community making sure it works?

As in, I can be sure that the `Blink` will always be able to display the output of `showtable` as long as `showtable` is a `WebIO.Scope`?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [July 21, 2020, 6:55pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/5 "2020-07-21T18:55:03Z")

</div>

Probably. Blink isn’t particularly well maintained at the moment and the same is somewhat true for WebIO itself.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [July 21, 2020, 6:58pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/6 "2020-07-21T18:58:07Z")

</div>

Thanks for the feedback. I will do the `WebIO.Scope` idea and then submit this for registration.

I think I’ve asked you this before, but if you could help me try and get this into a browser window, I’d really appreciate it. I can’t seem to navigate `Mux` and `WebIO` well enough.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [July 21, 2020, 6:59pm UTC](https://discourse.julialang.org/t/how-to-add-tests-for-an-interactive-package/43349/7 "2020-07-21T18:59:29Z")

</div>

WebIO is kinda buggy in that regard. I’m kinda short on time right now, but I’d love to see the browser integration (via HTTP.jl) directly in TableViews.jl.
