Search code examples
unit-testingtestingmstest

PublicForTests annotation in MSTest


As I know, in JUnit I can set @PublicForTests annotation for logic tests.
I tried to find alternative in MSTest with no success.

What I'v found is people who said that I don't need to test private methods.
What is my alternative to check my logic of private methods?


Solution

  • From our comments, there are 2 main approaches that you can take to test private methods:

    • The first is to indirectly test your private method via the public method that uses it.
    • The second is to directly test your private method via Reflection.