Forked from JoshCheek/before_all_and_after_all_in_minitst.rb
Created
January 22, 2019 09:09
-
-
Save alexanderadam/aaf5f2399968da8bdc6080cbc6b6576e to your computer and use it in GitHub Desktop.
Before all and after all in minitest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alert(color=:default, message) | |
colors = {default: 0, black: 30, red: 31, green: 32, orange: 33, blue: 34, magenta: 35, teal: 36, white: 37} | |
$stdout.puts "----\e[#{colors[color]}m#{message}\e[0m----" | |
end | |
alert :red, 'before all tests' | |
at_exit { alert :red, 'after all tests' } | |
require 'minitest/autorun' | |
class SomeTest < MiniTest::Test | |
i_suck_and_my_tests_are_order_dependent! | |
def setup | |
alert :orange, 'before each' | |
end | |
def teardown | |
alert :orange, 'after each' | |
end | |
def test_1 | |
alert :magenta, 'in test 1' | |
end | |
def test_2 | |
alert :magenta, 'in test 1' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment