to print how much time each test takes to run. However it would be nice to be able to see, say, the top 20 slowest tests.
I found some ways of doing it, but I don't quite like them:
Monkey-patching Minitest to create a custom reporter... NOPE. Also, seems like the only way to do this is creating a library out of it, rather than adding some simple code in your test_helper, for example. I tried this and couldn't make it work, but I didn't spend more than one hour on it.
Changing all our tests from the it syntax to the test_name_of_test syntax so that we can do bundle exec rake TESTOPTS='--verbose' | sort -t = -k 2 -g on the terminal. NOPE.
output to a file and manipulate its contents in pry, the poor man approach I'm following.
BTW, the slowest tests are of course the integration tests! (i.e., the web tests). At the moment of writing this I get:
"Federal Constituency Place Page::social block#test_0002_links to facebook share = 0.29 s = .",
"List of Representatives::person item::when person does not have an image#test_0001_shows a picture anyway (empty avatar) = 0.18 s = .",
"List of Representatives::person item#test_0001_links to the person page = 0.17 s = .",
"List of Representatives::person item#test_0004_links to area page = 0.15 s = .",
"List of Representatives::person item#test_0007_displays party name = 0.15 s = .",
"List of Representatives::person list#test_0001_lists all representatives = 0.14 s = .",
"List of Representatives::person item::when person has an image#test_0001_points to the right path = 0.14 s = .",
"Posts Page#test_0002_shows all posts = 0.13 s = .",
"Posts Page#test_0001_shows the title = 0.13 s = .",
"Posts Page::when displaying a post#test_0004_displays post excerpt = 0.12 s = .",
"Posts Page::when displaying a post#test_0003_displays post date = 0.12 s = .",
"List of Representatives::person item#test_0003_shows right area type name = 0.12 s = .",
"List of Representatives::person item::when person has an image#test_0003_has the name as alternative text = 0.12 s = .",
"Posts Page::when displaying a post#test_0001_links to post url = 0.11 s = .",
"List of Representatives::person item#test_0005_displays area name = 0.11 s = .",
"Federal Constituency Place Page::person item#test_0007_links to the person area = 0.10 s = .",
"Posts Page::when displaying a post#test_0002_displays post title = 0.10 s = .",
"Page::Place#test_0008_has all the people for that place = 0.10 s = .",
"List of Representatives::person item::when person has an image#test_0002_has an srcset = 0.10 s = .",
"List of Representatives#test_0001_shows the title = 0.10 s = ."
At the moment we can do:
to print how much time each test takes to run. However it would be nice to be able to see, say, the top 20 slowest tests.
I found some ways of doing it, but I don't quite like them:
minitest-reporters
gem, BUT dependencies!it
syntax to thetest_name_of_test
syntax so that we can dobundle exec rake TESTOPTS='--verbose' | sort -t = -k 2 -g
on the terminal. NOPE.^^^ :scream: :scream: :scream: :scream:
I'm sure there should be an easy way to do this.
BTW, the slowest tests are of course the integration tests! (i.e., the web tests). At the moment of writing this I get: