I need to test private function
How test private function ?
Collapse
X
-
Tags: None
-
Heya, PierpaoloScappa tura.
You can test private methods by temporarily making them public, or by modifying or creating a public method for the purpose of testing them.
Similarly, you can test abstract methods or classes by commenting out the 'abstract' keyword until you're done testing.Comment
-
What on earth are you talking about?Originally posted by pbmodsHeya, PierpaoloScappa tura.
You can test private methods by temporarily making them public, or by modifying or creating a public method for the purpose of testing them.
Similarly, you can test abstract methods or classes by commenting out the 'abstract' keyword until you're done testing.Comment
-
Testing private functions.... Oh, I get it. I'm getting so high-level, that I'm practically an astronaut :)Originally posted by r035198xWhat on earth are you talking about?
I dunno. OP put this in software development, so I just answered in terms of the context I'm used to.
In PHP, if you need to unit test a private method of a class, you can make it public temporarily and then set it back to private when you're done testing (I mean by manually altering the source code).
I can't recall ever actually having to do this, since I usually test my private methods as part of developing the public methods that depend on them, but everyone's got their own style, I suppose.Comment
Comment