Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use t.Fatal instead of t.Error #106

Open
sagikazarmark opened this issue May 23, 2020 · 0 comments
Open

Use t.Fatal instead of t.Error #106

sagikazarmark opened this issue May 23, 2020 · 0 comments
Labels
Milestone

Comments

@sagikazarmark
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Consider the following example:

func check(t gobdd.StepTest, ctx gobdd.Context, sum int) {
	received, err := ctx.GetInt("sumRes")
	if err != nil {
		t.Error(err)

		return
	}

	if sum != received {
		t.Error(errors.New("the math does not work for you"))
	}
}

Because t.Error does not cause the test to fail immediately, we need to return manually from the function.

Describe the solution you'd like
By using t.Fatal the test fails immediately, making the code more concise.

Describe alternatives you've considered
One could even use testify (assert and require).

Additional context
This is true for some of the internal code of gobdd.

@sagikazarmark sagikazarmark added enhancement New feature or request proposal labels May 23, 2020
@bkielbasa bkielbasa added this to the 1.1 milestone Jun 1, 2020
@bkielbasa bkielbasa modified the milestones: 1.1, 1.2 Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants