Question Alex Kogan · Nov 28, 2017

Is there a way to Run a Unit Test against Private method

Hello,

I was wondering if there is a way to maybe temporarily alter the [Private] tag dynamically or any other way to run a Unit test against class method, which has been labeled as [Private]?

I mean, I understand there is a workaround to create a non private class method inside this class, which will in turn call this private method  and run a Unit test on the non private method, but I am looking for a way to do this without altering the original class.

Thank you,

Alex

Comments

Timothy Leavitt · Nov 28, 2017

You could have your unit test class extend the class with the [Private] method, or (if that doesn't make sense or causes issues) write another class that your unit test loads that extends the class with the [Private] method and has another method that wraps it.

0
Alex Kogan  Nov 28, 2017 to Timothy Leavitt

Thank you Tim, will give it a try.

0