GithubHelp home page GithubHelp logo

Comments (2)

arnevm123 avatar arnevm123 commented on August 10, 2024 2

So basically I would want my diagnostic message on the line of the failure. The blue arrow should show this 😄
image

my config:

"nvim-neotest/neotest",
dependencies = {
	"nvim-lua/plenary.nvim",
	"nvim-treesitter/nvim-treesitter",
	"nvim-neotest/neotest-plenary",
	"nvim-neotest/neotest-go",
},
config = function()
	local neotest_ns = vim.api.nvim_create_namespace("neotest")
	vim.diagnostic.config({
		virtual_text = {
			format = function(diagnostic)
				local message =
					diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
				return message
			end,
		},
	}, neotest_ns)
	require("neotest").setup({
		diagnostic = {
			enabled = true,
			severity = 4,
		},
		adapters = {
			require("neotest-go")({
				experimental = { test_table = true },
			}),
		},
	})
end,

main.go:

package main

import "fmt"

func AddNoZero(a, b int) (int, error) {
	if a == 0 || b == 0 {
		return 0, fmt.Errorf("cannot add zero")
	}
	return a + b, nil
}

main_test.go

package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestAddNoZero(t *testing.T) {
	type args struct {
		a int
		b int
	}
	tests := []struct {
		name      string
		args      args
		want      int
		assertion assert.ErrorAssertionFunc
	}{
		{
			name: "correct test",
			args: args{
				a: 2,
				b: 5,
			},
			want:      7,
			assertion: assert.NoError,
		},
		{
			name: "another correct test",
			args: args{
				a: 8,
				b: 5,
			},
			want:      13,
			assertion: assert.NoError,
		},
		{
			name: "failing test",
			args: args{
				a: 7,
				b: 5,
			},
			want:      9,
			assertion: assert.NoError,
		},
		{
			name: "final correct test",
			args: args{
				a: 7,
				b: 5,
			},
			want:      12,
			assertion: assert.NoError,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := AddNoZero(tt.args.a, tt.args.b)
			tt.assertion(t, err)
			assert.Equal(t, tt.want, got)
		})
	}
}

from neotest-go.

sergii4 avatar sergii4 commented on August 10, 2024

Hi @arnevm123 could you please provide some screenshots? It would help understand what do you want to achive

from neotest-go.

Related Issues (20)

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.