sidlatau / neotest-dart

30 stars 8 forks source link

Unable to run tests for entire suite #12

Closed kamskr closed 7 months ago

kamskr commented 8 months ago

Hello,

I'm using neotest-dart with flutter-tools.nvim for a few months now, everything works great when I'm working with tests in a single file. However when I try to run tests for entire suite, tests immediately fail without any error message:

https://github.com/sidlatau/neotest-dart/assets/45424810/63d51937-5a79-4ab2-a273-dcdc23e75d4b

I tried those actions to run tests:

require('neotest').run.run(vim.fn.getcwd())

and

require('neotest').run.run({suite = true})

My configuration:

return {
  'nvim-neotest/neotest',
  dependencies = {
    'vim-test/vim-test',
    'nvim-lua/plenary.nvim',
    'nvim-treesitter/nvim-treesitter',
    'antoinemadec/FixCursorHold.nvim',
    'sidlatau/neotest-dart',
  },
  opts = function()
    return {
      -- your neotest config here
      adapters = {
        require 'neotest-dart' {
          command = 'fvm flutter', -- Command being used to run tests. Defaults to `flutter`
          -- Change it to `fvm flutter` if using FVM
          -- change it to `dart` for Dart only tests
          use_lsp = true, -- When set Flutter outline information is used when constructing test name.
          -- Useful when using custom test names with @isTest annotation
          custom_test_method_names = {},
        },
      },
    }
  end,
  config = function(_, opts)
    require('neotest').setup(opts)

    vim.keymap.set('n', '<leader>tr', function()
      require('neotest').run.run()
    end, { desc = 'Run closest test' })

    vim.keymap.set('n', '<leader>td', function()
      require('neotest').run.run { strategy = 'dap' }
    end, { desc = 'Debug closest test' })

    vim.keymap.set('n', '<leader>ta', function()
      require('neotest').run.run({suite = true})
    end, { desc = 'Run all tests' })

    vim.keymap.set('n', '<leader>to', function()
      require('neotest').output.open { enter = true }
    end, { desc = 'Open test output' })

    vim.keymap.set('n', '<leader>top', function()
      require('neotest').output_panel.toggle()
    end, { desc = 'Toggle test output panel' })

    vim.keymap.set('n', '<leader>tw', function()
      require('neotest').watch.toggle()
    end, { desc = 'Toggle test watcher' })

    vim.keymap.set('n', '<leader>ts', function()
      require('neotest').summary.toggle()
    end, { desc = 'Toggle test summary' })
  end,
}
hryacosta commented 8 months ago

I'm having the same problem!

@kamskr

praxder commented 8 months ago

Same problem! When I look up the test output I see a ton of this: CleanShot 2024-01-16 at 08 55 20

Hecatoncheir commented 7 months ago

I try to fix this. Looks like it worked:

https://github.com/sidlatau/neotest-dart/assets/910917/04e36017-3a78-4823-8a0b-b9b013561d73

sidlatau commented 7 months ago

The code is merged, thanks @Hecatoncheir! There is still a problem when multiline test names are used, the dir option does not handle this (registered https://github.com/sidlatau/neotest-dart/issues/16 ), but for single-line tests adapter works correctly.