2013年10月28日星期一

Chris Hartjes: Data Providers and Arrays


Chris Hartjes, testing guru, has a post talking about using arrays in data providers for your unit tests. More specifically about some odd behavior one developer was seeing in their tests.



I was asked a question on Twitter by Tex Morgan about a problem he was having with PHPUnit data providers. He was trying to pass in some data and kept wondering why PHPUnit was serializing the data instead of doing what he was expecting.


The issue (example code included) was in how the data providers are expecting the data to be returned. His test was expecting an array but the data provider was returning things incorrectly. As Chris points out, the provider should return an array of arrays. The fix is easy, but could be confusing to someone not used to this slightly unusual return format.


Link: http://www.littlehart.net/atthekeyboard/2013/10/26/data-providers-and-arrays/

没有评论:

发表评论