What's the recommended way of reusing tests? Examp...
# test
e
What's the recommended way of reusing tests? Example: there are 3 endpoints, and I want to test if all three of them handle authorization correctly, and the tests are the same, so I want to define the tests and reuse them, similar to rspec shared examples https://rspec.info/features/3-12/rspec-core/example-groups/shared-examples/
e
Is your authorisation handling code abstracted and reused for all end point?
e
yes. I could test the authorisation code, and then mock on the endpoint, which is good enough for unit test, but not for integration tests
e
Oke, up to you! As for me having unit tests and one integration test is enough to be comfortable with the regression catches.
c
probably depends on the test runner that you are using
if you use #failgood or #kotest you can just put your shared tests into a function and call that for example like this: https://github.com/failgood/failgood/blob/main/failgood-examples/src/test/kotlin/failgood/examples/ContractsTest.kt#L12
e
Yeah, I am considering kotest because of that, most developers use ruby here so they are very familiar with BDD