Quantcast
Channel: Sam Saffron's Blog - Latest posts
Viewing all articles
Browse latest Browse all 150

Tests that sometimes fail - flaky test tips

$
0
0

That is a very nice article, lots of good stuff there have not come across it.

I love the takeaway there " Treat your test code just like production code", I feel a lot of the slippery slope we find ourselves going through involves

  • Tests failed …

  • Oh it is just tests, does not matter.

The article by Keith talks about the importance of debugging, I 100% agree there, getting good logs can mean the difference between spending 5 minutes on a flaky test to multiple hours.

Kind of mixed on a strong requirement to reset sequences and super happy we get away without a database cleaner in Discourse cause we simply rewind PG transactions for cheaper fabrications of db chains. For us to have a DB state leak we need multiple threads involved.

@Andrew_Kozin regarding using 1,000,000 its one of those solutions that really irks developers though, in practice, works 100% of the time. If you are going with that kind of pattern a simpler trick is using negative numbers which are always out of sequence: User.create!(id: -1, name: 'bob') - some code base (Discourse included, does make some assumptions about negative ids, so your mileage may vary here)


Viewing all articles
Browse latest Browse all 150

Trending Articles