测试构造函数被多次调用的地方?

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

func TestNewPerson(t *testing.T) {
    firstName := "Barack"
    lastName := "Obama"
    birthYear := 1990

    p, err := NewPerson(firstName, lastName, birthYear)

    assert.Equal(t, err, nil, "Should not return error.")
    assert.Equal(t, p.FirstName, firstName, "First name came wrong.")
    assert.Equal(t, p.LastName, lastName, "Last name came wrong.")
    assert.Equal(t, p.BirthYear, birthYear, "Birth year name came wrong.")
}

func TestFullName(t *testing.T) {
    tests := []struct{
        firstName   string
        lastName    string
        fullName    string
    }{
        {"Hello", "World", "Hello World",},
        {"Barack", "Hussein Obama ", "Barack Hussein Obama",},
    }

    for _, obj := range tests {
        p, _  := NewPerson(obj.firstName, obj.lastName, 1990)

        assert.Equal(t, obj.fullName, p.FullName())
    }
}

This works fine. But what happens when I've written many tests, and then I need to make a change in the "NewPerson" constructor because I've added a new property to the struct?

I will then have to change all parameters of the calls to the constructors.

What's a solution for this? Should I look for a way to abstract this?

That kind of refactoring could (not tested) be taken care of with the command go fmt.

See "Refactoring with go fmt":

gofmt uses patterns to identify changes to make to your code. Patterns are established in the first half the expression followed by a ‘->’ then used by the second half of the expression.

Use the flag -d instead of -w to check what gofmt will do prior to running it.

gofmt -r "yourConstructor(x,y) -> yourConstructor(x, y, z)" -d ./

That works only if the pattern you specify is a valid go expression, as mentioned in this answer.