Testing, testing



  • A while back I felt the need to unit test some private methods, which may be a WTF in itself, but whatever. We use nunit so I couldn't use the private testing types from the Microsoft Test Framework, instead I made a couple of extension methods on System.Object that would via reflection let me invoke nonpublic methods. As barely anyone else wrote unit tests, I left it as an internal class in my test project. One day someone asks me about testing nonpublic methods, so I tell them I've got something that can help, gave them the SVN repository url and the name of the file. This file has now reappeared in a newly-created test framework library that someone here has put together, and it's also documented pretty well in our wiki.

    So where is the WTF?

    You have to reference this library, but the class and it's methods are still internal. I finally found out who took over the class and rolled it into the test framework library and asked them to change the extension method visibility from internal to public. their totally straight-faced reply?

    "No need to do that. You can just call them using reflection."



  • They should also call public methods using reflection, so as to have uniformity in the coding style.



  • @JimLahey said:

    "No need to do that. You can just call them using reflection."

    "There's a lot of things you can do but shouldn't. For example, murder the guy refusing to help you write your tests with a salad fork from the office kitchen."



  • @Reauiem said:

    They should also call public methods using reflection, so as to have uniformity in the coding style.
    How would you call the reflection methods though?

     



  • @Zecc said:

    @Reauiem said:

    They should also call public methods using reflection, so as to have uniformity in the coding style.
    How would you call the reflection methods though?

     

    Uniformly, duh.



  • @JimLahey said:

    You have to reference this library, but the class and it's methods are still internal. I finally found out who took over the class and rolled it into the test framework library and asked them to change the extension method visibility from internal to public. their totally straight-faced reply?

    "No need to do that. You can just call them using reflection."


    when all you have is hammer, you want your other hammer to be a nail too, I guess?

  • Considered Harmful

    @SEMI-HYBRID code said:

    when all you have is hammer, you want your other hammer to be a nail too, I guess?

    I built you a hammer, but you need a hammer to use it.



  • @joe.edwards said:

    I built you a hammer, but you need a hammer to use it.

    The Linux philosophy in a nutshell.


Log in to reply