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

Tests run more than once if should blocks follow context blocks #4

Closed
mvz opened this issue Dec 22, 2010 · 3 comments
Closed

Tests run more than once if should blocks follow context blocks #4

mvz opened this issue Dec 22, 2010 · 3 comments

Comments

@mvz
Copy link

mvz commented Dec 22, 2010

If there are should blocks following context blocks at the same level of nesting, the tests defined by the should blocks are executed more than once. The following example llustrates this:

require 'contest'

class FooTest < Test::Unit::TestCase
  context "a" do
    context "c" do
      should "d" do
        puts "B"
      end

      should "e" do
        puts "C"
      end
    end
    should "b" do
      puts "A"
    end
  end
end

If this code is run, "A" will be printed twice.

@mvz
Copy link
Author

mvz commented Dec 22, 2010

Note also that the tests are only run once if the should blocks precede the context blocks.

@philc
Copy link

philc commented May 12, 2011

A simpler test case:

require "rubygems"
require "contest"

class InheritanceProblem  < Test::Unit::TestCase
  should "test1" do
   puts "test1"
  end

  context "context1" do
    should "context_test1" do
      puts "context_test1"
    end
  end

  should "test2" do
    puts "test2"
  end
end

Has output:

test1
test2
context_test1
test2

@mvz
Copy link
Author

mvz commented Jul 8, 2016

It seems this was fixed ...

@mvz mvz closed this as completed Jul 8, 2016
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

2 participants