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

After should only be added if the step is used in the current scenario #4

Open
squeedee opened this issue Oct 28, 2020 · 0 comments
Open

Comments

@squeedee
Copy link
Contributor

Current behavior

var _ = Describe("Too many afters", func() {
	steps := NewSteps()

	var (
		oneCounter int = 0
		twoCounter int = 0
	)
	Scenario("first scenario", func() {
		steps.When("thing 1 is run")
	})

	Scenario("second scenario", func() {
		steps.When("thing 2 is run")
	})

	steps.Define(func(define Definitions) {
		define.Given(`^thing 1 is run$`, func() {
			oneCounter += 1
		}, func() {
			oneCounter -= 1
			Expect(oneCounter).To(Equal(0))
		})

		define.Given(`^thing 2 is run$`, func() {
			twoCounter += 1
		}, func() {
			twoCounter -= 1
			Expect(twoCounter).To(Equal(0))
		})

	})

})

Expects fail with

  Expected
      <int>: -1
  to equal
      <int>: 0

They should pass.

This happens because the after steps are added when the definitions are added, not when the step is encountered in a scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant