# Test Explorer UI

**URL:** <https://discourse.julialang.org/t/test-explorer-ui/16084>\
**Category:** VS Code\
**Created:** [October 9, 2018, 5:20pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084 "2018-10-09T17:20:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [October 9, 2018, 5:20pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/1 "2018-10-09T17:20:47Z")

</div>

Is there any chance of getting a Test Adapter to allow automatic unit testing in Julia with the Test Explorer extension?

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [October 10, 2018, 12:21am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/2 "2018-10-10T00:21:17Z")

</div>

In theory, maybe, but I don’t think anyone is working actively on that right now…PRs certainly welcome!

---

<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:** [October 10, 2018, 3:08am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/3 "2018-10-10T03:08:09Z")

</div>

@ZacLN sent me this example of using JuliaCST parser tech (which is the brains of the VS code plug in)  
to detect testsets:  
[https://gist.github.com/ZacLN/86f05bdf307974e28f58d437cdddc0ba](https://gist.github.com/ZacLN/86f05bdf307974e28f58d437cdddc0ba)

You can use this kinda stuff to find testsets and then also to workout which testsets can be run independently.

That would form the basis of a great unit testing UI system.  
idk if that is what Test Explorer does.

---

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [October 10, 2018, 9:47pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/4 "2018-10-10T21:47:01Z")

</div>

Test Explorer is a Node.js program, and the Julia plugin would probably have to be at least partly in javascript to work with the Node.js code.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [October 11, 2018, 12:53am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/5 "2018-10-11T00:53:27Z")

</div>

Large parts of the julia extension are written in TypeScript, really only the language server and some other smaller parts are written in julia.

---

<div class="post-metadata">

**Author:** ![Evgenii](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evgenii/32/9084_2.png) [@Evgenii](https://discourse.julialang.org/u/Evgenii)\
**Post date:** [June 30, 2019, 3:22am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/6 "2019-06-30T03:22:19Z")

</div>

Is there any progress here? I would like to have a UI in VS Code for running tests, especially for running a **single test** , similar to Python:

 ![python_test](https://global.discourse-cdn.com/julialang/original/3X/f/a/fab5bd7329a278f76a0328818b8121aa2d384f50.png)

I’m new to Julia, came from Swift/JavaScript. I could not find a way to run a [single unit test](https://discourse.julialang.org/t/test-specific-test-sets-in-julia-v0-5/378), which is crucial for test driven development (I don’t want to run all tests after each key stroke). Is it why there is no unit test integration in VS Code? 🙂

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [June 30, 2019, 5:51am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/7 "2019-06-30T05:51:55Z")

</div>

No support for that. I also wouldn’t know how to do this in general with the current Julia test design: most test suites are designed as one long script, not as a compilation of individual tests that could be run e.g. out of order.

---

<div class="post-metadata">

**Author:** ![Evgenii](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evgenii/32/9084_2.png) [@Evgenii](https://discourse.julialang.org/u/Evgenii)\
**Post date:** [June 30, 2019, 6:41am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/8 "2019-06-30T06:41:17Z")

</div>

I see, thanks. Do you think it will be useful for us to create a test runner, similar to pytest in Python or rspec in Ruby?

What if we created a test runner that comes with a `jutest` executable? Suppose we have our code structure like this:

```julia
Animals/
├-- possum.jl
├-- possum_test.jl
├-- dolphin.jl
└-- dolphin_test.jl

```

Notice that the test files are placed together with code, and not in a separate `test` directory, to make it easier to find/write tests. 🙂

Now we can run all our tests from Linux terminal, which will automatically run files that end with “\_test.jl”.

```julia
> jutest

```

Or, we can run an individual file:

```julia
> jutest dolphin_test.jl

```

Or, like in pytest or mocha, we can run individual test sets that match the given text:

```julia
> jutest -grep "like to play"

```

Something like this :). Will this be useful to anybody?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 30, 2019, 11:28am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/9 "2019-06-30T11:28:42Z")

</div>

The ability to test single units of tests in Julia would be tremendously helpful.

Most package that I contribute to have a top-level `runtests.jl` file that includes a bunch of small test unit files, which in theory could be tested separately. Right now because of the current design of Test, we can’t just test a single file without also loading the `runtests.jl` file.

As already mentioned, the ability to test a single file would be very useful in test-driven development. I often see myself copying snippets of code to my test files manually. Being able to just write down a script with tests, and then include it in `runtests.jl` later would be great.

---

<div class="post-metadata">

**Author:** ![sgryjp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgryjp/32/8701_2.png) [@sgryjp](https://discourse.julialang.org/u/sgryjp)\
**Post date:** [June 30, 2019, 12:26pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/10 "2019-06-30T12:26:31Z")

</div>

If the test runner provides us better control of what to test (filtering) and/or how to test (out of order execution etc.) then it’s absolutely useful for me. Oh, implementing file level filtering in `test/runtests.jl` is rather easy ([like this](https://github.com/sgryjp/CliOptions.jl/blob/7697432692c09ac5cc6136ac55f2fcf0db6a7abe/test/runtests.jl)) so what I expect is more precise control like `-k` of `pytest` (`-grep` in your example 🙂 )

By the way, it might be better to provide a way to execute the runner **by executing `test/runtests.jl`**. Since the `test` command of Pkg REPL mode executes the file, I believe majority of projects will continue using the file as an entry point.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 30, 2019, 12:27pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/11 "2019-06-30T12:27:02Z")

</div>

You can easily make each individual test file standalone by adding the necessary using commands to each one.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 30, 2019, 12:32pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/12 "2019-06-30T12:32:04Z")

</div>

> [@juliohm](#):
>
> the ability to test a single file would be very useful in test-driven development.

FWIW, a relatively easy solution is to have them `include`d from separate files, then comment out what you don’t need, and revert everything from `git` before committing.

A bit more complicated system could communicate with the inferior process via an environment variable — if set, run only the tests that match, if not, run all. A simple `withenv` wrapper to `Pkg.test` would take care of the rest.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 30, 2019, 12:35pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/13 "2019-06-30T12:35:00Z")

</div>

Yes, but that is sub-optimal. Ideally we would have a proper treatment of the issue.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 30, 2019, 12:36pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/14 "2019-06-30T12:36:16Z")

</div>

> [@Tamas\_Papp](#):
>
> FWIW, a relatively easy solution is to have them `include` d from separate files, then comment out what you don’t need, and revert everything from `git` before committing.

That is what I currently do. I comment out all the other files in my `runtests.jl`, and then uncomment then when I am ready to include the new test unit. It works for small projects, but is sub-optimal.

---

<div class="post-metadata">

**Author:** ![Evgenii](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evgenii/32/9084_2.png) [@Evgenii](https://discourse.julialang.org/u/Evgenii)\
**Post date:** [June 30, 2019, 2:47pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/15 "2019-06-30T14:47:50Z")

</div>

> If the test runner provides us better control of what to test (filtering) and/or how to test (out of order execution etc.) then it’s absolutely useful for me. Oh, implementing file level filtering in `test/runtests.jl` is rather easy ([like this](https://github.com/sgryjp/CliOptions.jl/blob/7697432692c09ac5cc6136ac55f2fcf0db6a7abe/test/runtests.jl)) so what I expect is more precise control like `-k` of `pytest` ( `-grep` in your example 🙂 )

Thanks for the link. I think we could write a very similar code, release it as a test runner package. And then call a method from the test runner in `test/runtests.jl` that will automatically locate and include all the unit test files. That’s for package creators.

At the same time, if I just want to write test for my code, I don’t even need to have `test/runtests.jl`. I create test files, put them wherever I like, and run selected tests with a simple command from a shell. Same way this is done in many other languages like Ruby or JavaScript.

And then we can create an extension for VSCode that will use the test runner to locate and run tests from the UI.

That’s the idea. 🙂

---

<div class="post-metadata">

**Author:** ![wookyoung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wookyoung/32/157_2.png) [@wookyoung](https://discourse.julialang.org/u/wookyoung)\
**Post date:** [June 30, 2019, 2:55pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/16 "2019-06-30T14:55:11Z")

</div>

Would you like to see Jive.jl? that’s a package to help the testing.

> **[GitHub - wookay/Jive.jl: some useful steps in tests 👣](https://github.com/wookay/Jive.jl)**
>
> some useful steps in tests 👣. Contribute to wookay/Jive.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [July 1, 2019, 8:12am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/17 "2019-07-01T08:12:33Z")

</div>

I’d love to see support for more fine-grained test execution, but I think from the VS Code extension point of view we would wait until something appear in Base and then support that. Not a hard rule, but that is my gut feeling right now.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 1, 2019, 10:51am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/18 "2019-07-01T10:51:33Z")

</div>

Thank you @wookyoung, I will take a look at Jive.jl, it is great. 🙂

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 1, 2019, 10:56am UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/19 "2019-07-01T10:56:53Z")

</div>

@wookyoung could you maybe share an example of a top-level runtests.jl file with a collection of small test units in separate files that Jive can run one-by-one?

I understand that we can either run each test file separately or run the entire runtests.jl, is that correct?

---

<div class="post-metadata">

**Author:** ![wookyoung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wookyoung/32/157_2.png) [@wookyoung](https://discourse.julialang.org/u/wookyoung)\
**Post date:** [July 1, 2019, 2:25pm UTC](https://discourse.julialang.org/t/test-explorer-ui/16084/20 "2019-07-01T14:25:21Z")

</div>

OK. I’ve created another simple package, visit here

> <https://github.com/wookay/TestJive.jl/tree/master/test>
>
> //github.com/wookay/TestJive.jl/tree/master/test

> I understand that we can either run each test file separately or run the entire runtests.jl, is that correct?  
> yes you could.
