Unit Testing: Beginner Questions

后端 未结 4 751
陌清茗
陌清茗 2021-01-31 12:14

I\'m finally starting out with unit testing, having known that I should be doing it for a while, but I have a few questions:

  • Should or shouldn\'t I retest parent c
4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 12:47

    Answers to questions in order:

    • If parent classes are already tested then avoid duplication and just test the new aspects of the child or any aspects that the child changed.
    • Not sure - have done very little PHP.
    • Yes => test all aspects of the method.
    • You could have some unit tests that test performance but they would be focused on performance where as others may be focused on testing functionality. Don't mix both in the same test.
    • Ideally you should run them every time and often. Sometimes if the execution time is huge you might want to consider refactoring them into smaller suites and then only executing the effected suites when something changes - but still do everything periodically.

提交回复
热议问题