Git Product home page Git Product logo

neotest-dotnet's Introduction

Neotest .NET

Neotest adapter for dotnet tests

NOTE - This is a WIP project and will be under development over the coming months with additional features

  • Please feel free to open an issue

Pre-requisites

neotest-dotnet requires makes a number of assumptions about your environment:

  1. The dotnet sdk that is compatible with the current project is installed and the dotnet executable is on the users runtime path (future updates may allow customisation of the dotnet exe location)
  2. The user is running tests using one of the supported test runners / frameworks (see support grid)
  3. (For Debugging) netcoredbg is installed and nvim-dap plugin has been configured for netcoredbg (see debug config for more details)
  4. Requires nvim-treesitter and the parser for C#.

Installation

  use({
    "nvim-neotest/neotest",
    requires = {
      {
        "Issafalcon/neotest-dotnet",
      },
    }
  })
    Plug 'https://github.com/nvim-neotest/neotest'
    Plug 'https://github.com/Issafalcon/neotest-dotnet'

Usage

require("neotest").setup({
  adapters = {
    require("neotest-dotnet")
  }
})

Additional configuration settings can be provided:

require("neotest").setup({
  adapters = {
    require("neotest-dotnet")({
      -- Extra arguments for nvim-dap configuration
      -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values
      dap = { justMyCode = false },
      -- Let the test-discovery know about your custom attributes (otherwise tests with not be picked up)
      -- Note: Only custom attributes for non-parameterized tests should be added here. See the support note about parameterized tests
      custom_attributes = {
        xunit = { "MyCustomFactAttribute" },
        nunit = { "MyCustomTestAttribute" },
        mstest = { "MyCustomTestMethodAttribute" }
      }
    })
  }
})

Debugging

Screencast.from.10-23-2022.01.40.06.PM.webm
  • Install netcoredbg to a location of your choosing and configure nvim-dap to point to the correct path
  • The example below uses the mason.nvim default install path:
local install_dir = path.concat{ vim.fn.stdpath "data", "mason" }

dap.adapters.netcoredbg = {
  type = 'executable',
  command = install_dir .. '/packages/netcoredbg/netcoredbg',
  args = {'--interpreter=vscode'}
}

NOTE: When debugging, the result output is currently not correctly relayed back to neotest (it instead reads the output from the debugger process, and registers all tests run using the 'dap' strategy as failed). The correct test feedback is displayed in a terminal window as a workaround for this limitation. This will also affect the output in the neotest-summary window. Hopefully this will be fixed in time.

Support

Key

✔️ = Fully supported

〽️ = Partially Supported (functionality might behave unusually)

⁉️ = As yet untested

❌ = Unsupported (tested)

Runner / Framework Unit Tests *Parameterized Unit Tests (e.g. Using TestCase attribute) Specflow Debugging
C# - NUnit ✔️ ✔️ ✔️ ✔️
C# - XUnit ✔️ ✔️ 〽️ (issues with test name linking) ✔️
C# - MSTest ✔️ ✔️ ✔️ ✔️
F# - NUnit ⁉️ ⁉️ ⁉️ ⁉️
F# - XUnit ⁉️ ⁉️ ⁉️ ⁉️
F# - MSTest ⁉️ ⁉️ ⁉️ ⁉️
  • Parameterized tests are only itemized by the adapter when the attribute arguments are inline values. For any parameterized test attributes (including custom ones) that take non-inlined values the adapter will lump all these tests together in one.

Limitations

  1. A tradeoff was made between being able to run parameterized tests and the specificity of the dotnet --filter command options. A more lenient 'contains' type filter is used in order for the adapter to be able to work with parameterized tests. Unfortunately, no amount of formatting would support specific FullyQualifiedName filters for the dotnet test command for parameterized tests.
  2. See the support guidance for feature and language support
  1. As mentioned in the Debugging section, there are some discrepancies in test output at the moment.

neotest-dotnet's People

Contributors

adelarsq avatar charleslambert avatar fen avatar frederikrosenberg avatar issafalcon avatar rcarriga avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.