You don’t want your tests to fail every time the date or time changes. Before comparing against the approved output, you can filter out the parts that vary.
Spend 2 minutes individually writing down problems you anticipate or aspects you don’t understand about using a Text-Based Approval testing approach on your application. Share them with the group.
Hopefully someone will mention things like dates and process IDs in the output. (File away other problems they raise for another occasion.)
Give them the Supermarket-Receipt-Refactoring-Kata on the ‘with_date’ branch. Show them all the failing tests and give them a few minutes to come up with strategies to fix the problem.
Demo filtering the dates by adding run_dependent_text in the config file.
Give them the Approvals Puzzles repo and point them at the ‘quizz’ application (puzzle 1). Ask them to write a test for it that passes consistently.
Today we needed to write some regular expressions to filter out unwanted dates and times. Is this a viable solution to any of the problems you came up with in the connect part of today’s learning hour? Can you think of any situations where output varies but a regular expression is totally the wrong tool for the job?
Discuss in pairs or whole group if it is small.
Some ideas to inject if they can’t think of any situations when regexes dont work well: - Output is unsorted but otherwise consistent - Output is structured as xml and you want to remove a particular tag only when it appears in a particular part of the xml tag hierarchy.