Skip to content

Conversation

@samwcoulter
Copy link
Contributor

@samwcoulter samwcoulter commented Oct 27, 2025

Edit: This PR adds support for (automatically) selecting a .runsettings file that is located in the test project directory. If more than one .runsettings file is present, the user is given a choice via vim.ui.select. The user can also specify a custom .runsettings selector function via the plugin configuration. I have also added a configuration option for the vstest client communication timeout.

Notably missing from this PR are automated tests, and MTP/.testconfig.json support. My current platform (linux/ubuntu) does not yet have an easy to obtain release of .NET10, but I will open a new PR to add MTP support once I can easily test it locally.

WIP PR, looking for feedback.

MTP has abandoned the .runsettings format in favour of testconfig.json, so we will need to add client specific support for each.

@samwcoulter samwcoulter changed the title WIP: Add support for .runsettings and .testconfig.json Add support for .runsettings and .testconfig.json Oct 30, 2025
@samwcoulter samwcoulter changed the title Add support for .runsettings and .testconfig.json Add support for .runsettings with vstest Oct 30, 2025
@Nsidorenco
Copy link
Owner

Super nice that you’re implementing this!
I’m on vacation for the next couple of weeks so I won’t be able to look at this until then 😄

@froats
Copy link

froats commented Nov 4, 2025

I have been trying this with following config:

require("neotest").setup({
      log_level = vim.log.levels.TRACE,
      adapters = {
        require("neotest-vstest")({
          settings_selector = function(project_dir)
            -- Try to find .runsettings file in project root or common locations
            local runsettings_paths = {
              os.getenv("GIT_WORK_TREE") .. "/.runsettings",
            }
            for _, path in ipairs(runsettings_paths) do
              if vim.fn.filereadable(path) == 1 then
                vim.notify("Using runsettings file: " .. path)
                return path
              end
            end
            return nil -- let the adapter choose default
          end,
        }),
      },

Then in my .runsettigns:


<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Coverlet collector configuration for automatic code coverage -->
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <!-- Output format: lcov for neotest compatibility -->
          <Format>lcov</Format>
          
          <!-- Output filename for coverage data -->
          <CoverletOutputFileName>coverage.info</CoverletOutputFileName>
          
          <!-- Output coverage.info to test project directory -->
          <CoverletOutputDirectory>./app/tests/BasicService.Tests</CoverletOutputDirectory>

          <!-- Include only the main project, exclude test projects -->
          <Include>[BasicService]*</Include>
          <Exclude>[BasicService.Tests]*,[*.Tests]*,*Tests.dll</Exclude>

          <!-- Exclude compiler-generated and auto-property code -->
          <ExcludeByAttribute>GeneratedCodeAttribute,CompilerGeneratedAttribute,ObsoleteAttribute,ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>

          <!-- Skip auto-properties from coverage -->
          <SkipAutoProps>true</SkipAutoProps>

          <!-- Use source linking for better coverage analysis -->
          <UseSourceLink>true</UseSourceLink>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>

  <!-- Run configuration -->
  <RunConfiguration>
    <TreatNoTestsAsError>false</TreatNoTestsAsError>
  </RunConfiguration>
</RunSettings>

No file coverage is created though... Could you help me with this?

@samwcoulter
Copy link
Contributor Author

@froats Hmm, I can try to debug.

Is your custom settings selector finding the right file?

If you run the tests with dotnet test --settings <PATH_TO_RUNSETTINGS> <PATH_TO_TESTPROJECT_CSPROJ> Is the coverage generated?

@samwcoulter
Copy link
Contributor Author

@froats I found an issue when a customs settings selector is used. Please try the latest revision from my fork.

@froats
Copy link

froats commented Nov 5, 2025

Hi, it is taking the file properly now, the coverage is still not being created though.. I will have to check why

- Adding support for the (automatic) selection of a .runsettings file in
  a test project.
- If more than one .runsettings file is present in a project directory,
  vim.ui.select is used to query the user for their choice.
- Added a configuraiton option that allows the user to specify a function
  to find (or choose) a .runsettings file given a target project directory
- Added an optional configuration option that allows the user to specify
  a timeout to use when communicating with the vstest client
@Nsidorenco
Copy link
Owner

This looks really good, thank you for contributing!

Did you learn anything of why your coverage file was not generated @froats?

@Nsidorenco Nsidorenco linked an issue Nov 24, 2025 that may be closed by this pull request
@Nsidorenco
Copy link
Owner

I'll go ahead and merge this now. Thanks!

@Nsidorenco Nsidorenco merged commit c6ded25 into Nsidorenco:main Nov 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support for .runsettings

3 participants