- 对测试数据的测试也是单位测试的地方也是可能的，因为如果有数据与否，从技术上是可以通过的 - 从我理解的单元测试中来看。
I am testing a module that I am writing against the Unit Testing framework that comes with Drupal 7. All makes sense, and everything asserts as it should.
My question though, is it possible to run test cases against test data?
I can think of a few options/answers:
Should functionality testing be done in a different place than the SimpleTest framework? Or is there a way to test against data sets?
Drupal 8 contains tests for verifying an upgrade from Drupal 7 would be executed correctly. Those tests basically create Drupal 7 tables, fill them with the required values, and call update.php.
You could need to create a upgrade/update test for your module, or you could test how a function behaves when it reads data from the database that are not in the format it expects.
In the first case, you would need to override the
setUp() method, and avoid calling
parent::setUp(); in the second case, you would fill the database table used from the test with the test data, call the function, and check what the return value is.
Apart from testing an update, I can think only of a case where a test would need to fill a database table, since:
If the table contains what entered from users, then the test should verify the form validation handler correctly shows error for wrong input
If the table contains data entered from another module, that module should be using a function your module implements, and the test should just check what the function does when it receives wrong/unexpected values
It could be your module is using data from a table that is created from another module, which is not exposing an API to load/save data in that table. In that case, if you know there is another module that enters unexpected data, you could need to verify your module is able to handle that data.