nvim-neotest / neotest-python

MIT License
115 stars 34 forks source link

How to run all tests? #48

Closed fredrikaverpil closed 1 year ago

fredrikaverpil commented 1 year ago

Hi! 👋

I'm using LazyVim and it comes with a pre-configured command (click "full spec") for running all tests:

{ "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },

However, this command does nothing for me.

I've got my neotest-python adapter set up like this (full config here):

adapters = {
  require("neotest-python")({
    runner = "pytest",
    args = { "--log-level", "INFO", "--color", "yes", "-vv", "-s" },
  }),

Am I doing something wrong here?

More info:

Steps to reproduce:

  1. Launch neovim from the python project root dir with virtualenv activated. Open a test file.
  2. Run the require("neotest").run.run(vim.loop.cwd()) command via LazyVim's preconfigured <leader>tT.
  3. Observe how no tests are running in the test summary tree, or in the output panel.
catanzaromj commented 1 year ago

Here's what works for me (I got these from the neotest docs):

To run all tests in the current file:

function()
        require("neotest").run.run(vim.fn.expand("%"))
      end,

To run all tests in the current project:

      function()
        require("neotest").run.run(vim.fn.getcwd())
      end,

Can you try these and see if they work?

fredrikaverpil commented 1 year ago

@catanzaromj yes, they both work for me.

I also think something was wrong with my setup, because now the require("neotest").run.run(vim.loop.cwd()) command works too... 🤷 😆

I'll close this issue.