2

parameterized unit tests are often unfucking readable in my opininon

Comments
  • 2
    What does that look like?
  • 0
    Like TestX(self, foo:str, bar: int) (python example)
  • 1
    Unreadability is optional.
  • 0
    I like the laravel way of writing test methods: "it_doesnt_allow_a_user_to_sign_up_twice()"

    Then there is no need for a comment and if the sentence gets to long when writing integration tests, the test should be a unit test and not integration...
  • 0
    Also when it comes to tests: make them readable and forget about all oop rules like single responsibility etc etc.

    Tests are all about readability and making sure something works as expected. If you have to copy 10 lines of code for each method in your test then do it if it makes them easier to read.
  • 2
    Parameterized tests can be a good idea but if not used carefully can be harder to understand.

    Making more explicit tests for all edge cases is often more clear but especially if you want a lot of test cases it can be a time saver, especially to begin with.

    And later you break out more specifics.
  • 0
    @dmoen then a change request comes in and you fix 100x the copied lines is awful. No need fir OOP, but if you use it 10 times. It deserves a function/method.
Add Comment