Last week ( • Testing HTMX with Playwright ) we learned how to test our HTMX interactions with the Playwright browser testing library.
The resulting tests were more signal than noise though, so this week we look at extracting useful and reusable abstractions from the raw code. On the way we learn some useful techniques to extend a Java library with Kotlin.
In this episode
00:00:31 Reviewing the current code
00:01:43 The tests are still flakey
00:02:57 Removing a Thread.sleep
00:07:44 Extract extension functions
00:10:28 Review the test
00:10:50 Running the server on a random unused port
00:11:24 Cleaning up the server
00:11:46 Extracting boilerplate into a lifecycle function
00:14:05 Parameterising all the things
00:17:27 Extract utilities into their own file
00:19:41 Commit
00:19:56 Using null as a default parameter value
00:22:11 Amend commit
00:22:17 Using our utilities in an add item acceptance test
00:23:19 Reviewing the new test
00:24:01 Commit
00:24:35 Review
This is part 89 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist
• All Gilded Rose Episodes
and the code on GitHub
https://github.com/dmcg/gilded-rose-tdd
If you like this, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook
(http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.
Смотрите видео Extending A Java Library with Kotlin онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Pairing with Duncan 25 Август 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 714 раз и оно понравилось 37 людям.