How to write Unit Tests for functions that rely on dynamic data?

后端 未结 6 2139
萌比男神i
萌比男神i 2021-02-06 01:30

Lets say you have a website, that uses a function to retrieve data from the database and returns the result to be displayed/parsed/etc...

Since the data that is retrieve

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-06 02:03

    You can't, really. You'll need a guaranteed static set of data to create reliable unit tests. Perhaps a database snapshot will work for you.

    Dynamic data can be useful in other ways, such as to perform regression testing...

提交回复
热议问题