Skip to content

Go. Incorrect generation of tests for functions with specific signature #2284

@egiptipavel

Description

@egiptipavel

Description

Incorrect generation of tests for functions that have no parameter name or an blank name.

To Reproduce

Steps to reproduce the behavior:

  1. Write the following functions:
func foo(_ int) {

}

func bar(int) {

}
  1. Use plugin to generate tests

Expected behavior

Similar to this file should be generated.

package simple

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestFooByUtGoFuzzer(t *testing.T) {
	arg := 0

	assert.NotPanics(t, func() {
		foo(arg)
	})
}

func TestBarByUtGoFuzzer(t *testing.T) {
	arg := 0

	assert.NotPanics(t, func() {
		bar(arg)
	})
}

Actual behavior

package simple

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestFooByUtGoFuzzer(t *testing.T) {
	 _ := 0

	assert.NotPanics(t, func() {
		foo(_)
	})
}

func TestBarByUtGoFuzzer(t *testing.T) {
	 := 0

	assert.NotPanics(t, func() {
		bar()
	})
}

Environment

There is no specific environment.

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a buglang-goIssue is related to Go support

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions