Dynamically create PHPUnit tests from data-file
Posted
by DeletedAccount
on Stack Overflow
See other posts from Stack Overflow
or by DeletedAccount
Published on 2009-11-30T20:25:13Z
Indexed on
2010/04/14
4:23 UTC
Read the original article
Hit count: 234
I have a data file with input and expected outputs. An example could be:
input: output:
2 3
3 5
4 Exception
5 8
... ...
Currently I have a custom solution to read from the data file and perform a test for each {input,output} pair. I would like to convert this into a PHPUnit based solution and I would like to have one test per input using the test name forXassertY. So the first three tests would be called for2assert3(), for3assert5() and for4assertException().
I do not want to convert my existing data to tests if it's possible to create the test methods dynamically and keep the data file as the basis of these tests. I want to convert it to PHPUnit as I want to add some other tests later on and also process and view the output using Hudson.
Suggestions?
© Stack Overflow or respective owner