Using swift-testing with Neovim and neotest

Hi there,

I wrote a neotest adapter for swift-testing to use in Neovim. Check it out in GitHub.

Features

  • - Run Swift Test suites and tests
  • - Debug tests cases with neotest dap support

I developed for Xcode 16, working for my needs so far but feel free to give feedback to help me improve it.

5 Likes

I’ve managed to get this installed with my LazyVim setup (I think) but if I use tt I get this message:

[neotest-swift-testing]|DEBUG|2025-09-02T16:32:52Z+1000|...neotest-swift-testing/lua/neotest-swift-testing/init.lua:433 Position not found: h2hTests.h2hTests/

Is there a place I should be configuring paths or something? If you can help me figure it out, I’d be glad to submit a PR documenting it nicely for others.

Hi Sarah, thanks for providing feedback. Can you provide a sample project for me to reproduce the issue?

1 Like

Thank you for looking at this, Markus!

I decided to try to find minimal steps to reproduce this and here they are. I’m working on a Vapor project and it turns out their default “hello world” project can reproduce this behaviour for me.

On the command line:

brew install vapor
vapor new hello -n
cd hello
swift build
nvim Tests/helloTests/helloTests.swift

Then in LazyVim I type tT to run all tests, and see the output below:

I’m new to LazyVim (but old enough to have used the original vi extensively), so I may have broken something in my configuration. Given that, I’ve linked to a .tgz file containing my .config/nvim directory contents. I haven’t tried sharing with dropbox before so let me know if it doesn’t work:

https://www.dropbox.com/t/4AZFRviwu9is63YA

Thank you so much for looking into this!

– Sarah

@sarah , do you have treesitter configured for Swift? I believe the neotest-swift-testing plugin uses a Treesitter query for test discovery, so you’d need to configure that in your LazyVim setup.

Here’s an example spec for lazy.nvim:

{
    "nvim-treesitter/nvim-treesitter",
    branch = 'master',
    lazy = false,
    build = ":TSUpdate",
    opts = {
        ensure_installed = { "swift" },
    }
},

I’m not super familiar with LazyVim, so you’ll have to refer the distro’s docs for guidance on how to add it. However, best I can tell, Swift isn’t enabled by default: TreeSitter | LazyVim

It rings a bell but I’ll check my configuration to make sure. It might take me a day or so to get back to my personal projects computer but I’ll have the info soon.

Thank you Jerry! I now have tests working (failing yes, but that’s my problem – I can run the tests!)

LazyVim’s website lists tree-sitter and many of its plugins list it as a dependency but I think they use the library not the command line?

I added your suggested configuration into .config/nvim/lua/plugins to ensure LazyVim was loading it and suddenly got different messages, about not finding the tree-sitter command line and then when I installed that about not finding node.

This got it fixed:

brew install tree-sitter-cli
brew install node

Then at last a beautiful sight:

The gutter is showing my tests as failing (which is just environment variable config stuff I can sort out myself, not related to nvim testing).

Thank you so much! Would you like for me to make a PR for your readme listing the steps I needed to get it going in LazyVim?