What is the reasoning behind MiniTest's lack of support for
`before :all` / `after :all` ?
I can understand that one should keep setup procedures to a minimum,
but are their not use cases where pre-testcase setup is really needed
-- logging into a database or service, for example?
Maybe I'm wrong but I was going through some Ruby standard libraries
just the other day and I saw this:
···
##
# Define a 'before' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to MiniTest::Unit::TestCase#setup.
def self.before type = :each, &block
raise "unsupported before type: #{type}" unless type == :each
define_inheritable_method :setup, &block
end
##
# Define an 'after' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to MiniTest::Unit::TestCase#teardown.
def self.after type = :each, &block
raise "unsupported after type: #{type}" unless type == :each
define_inheritable_method :teardown, &block
end
Keep in mind I don't use minitest so that might not be what you're
after.
That's just elucidating my question. Read the line:
raise "unsupported before type: #{type}" unless type == :each
I'm asking about `:all`,
···
On Aug 9, 5:16 pm, luke gruber <luke....@gmail.com> wrote:
>Thomas Sawyer wrote in post #1015734:
> What is the conventional thinking on this topic?
Maybe I'm wrong but I was going through some Ruby standard libraries
just the other day and I saw this:
##
# Define a 'before' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to MiniTest::Unit::TestCase#setup.
def self.before type = :each, &block
raise "unsupported before type: #{type}" unless type == :each
define_inheritable_method :setup, &block
end
##
# Define an 'after' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to MiniTest::Unit::TestCase#teardown.
def self.after type = :each, &block
raise "unsupported after type: #{type}" unless type == :each
define_inheritable_method :teardown, &block
end
Keep in mind I don't use minitest so that might not be what you're
after.