When I write the tests first, it gives me a feel for how consumers of the API will use it. It's a great method to understand the UX of the re-usable code.
> A test is the first user of your code
[1] The Pragmatic Programmer 20th Anniversary Edition (Thomas, Hunt)
I expand on this specific point in a blog post: https://www.buildthestage.com/just-enough-automated-tests/
> A test is the first user of your code
[1] The Pragmatic Programmer 20th Anniversary Edition (Thomas, Hunt)