nvim-neotest / neotest-go

MIT License
124 stars 43 forks source link

Feat - Add Support for Nested Subtests #74

Open sekerez opened 5 months ago

sekerez commented 5 months ago

Summary

As far as I can tell, neotest-go currently lacks support to run individual nested subtests. Specificallly, it will fail to initiate the right sub-subtest when running the nearest test. I'm working on a PR to add support.

Root cause

The utils.get_prefix, which derives the test to pass to go test -run, assumes that subtests only go one level deep. I fixed that for now, but the results still aren't parsed correctly - I'll publish my PR once I fix that.

Reproduction steps

Create a test file as such:

package main

import (
    "testing"

    "github.com/test-go/testify/require"
)

func TestHello(t *testing.T) {
    t.Run("World", func(t *testing.T) {
        require.Equal(t, "Hello, World!", hello("World"))
    })
    t.Run("Afterlife", func(t *testing.T) {
        t.Run("Heaven", func(t *testing.T) {
            require.Equal(t, "Hello, Heaven!", hello("Heaven"))
        })
        t.Run("Hell", func(t *testing.T) {
            require.Equal(t, "Hello, Hell!", hello("Hell"))
        })
    })
}
  1. Hover over t.Run("World", ... and run require("neotest").run.run(), observe that the test runs correctly.
  2. Hover over t.Run("Heaven", .., and run require("neotest").run.run(), observe that the test is skipped.