Use Case: I'm trying to create a diagnostic test for my unit testing framework that runs each test case and then returns a list of public methods which have not yet been covered by the test case. The idea is to get increased test coverage by making sure that all public methods of each are tested by at least 1 unit test.
Problem: I'm having trouble detecting if a method from a class has been called. I've tried using the debug_backtrace() function, but it only returns calls from the test framework, not the class method being tested. The only way I can get the method name being run is to actually place the debug_backtrace() function into the method of the tested class, which is an unacceptable option because I would have to have it in every public method of every class.
Is there an alternate way of doing the backtrace to get the tested class method? Or, in a slightly different approach, is there a way to start and stop a listener that will record all methods that are being called (I can parse out anything that doesn't belong)?
Pseudo-code:
runTest($testName){
//run the test
//get all recent classes and methods used
//parse out test framework info
//compare used public methods to public method list for the tested class
}
Or:
runTest($testName){
//start listener
//run the test
//close listener, get all recent classes and methods used
//parse out test framework info
//compare used public methods to public method list for the tested class
}