There are lots of neat tricks: 1. You can use MbUnit's "Reflector" class to manipulate private members. http://vkreynin.wordpress.com/2007/09/05/mbunit-testing-internal-classes /
2. If you need to override some of the behavior of the component under test during testing, you can either use dependency injection or you can move the code you want to override to a protected virtual method and use a subclass of the component in your tests. 3. If you have "internal" members you can use the [InternalsVisibleTo] attribute to make them accessible from your test assembly. 4. You may discover useful refactoring opportunities by examining components that are especially hard to test. Perhaps those components are doing too much work or perhaps the tests you have in mind are too complicated. 5. Don't be afraid to use integration testing methodologies in tandem with unit testing. http://blog.bits-in-motion.com/2007/10/but-xunit-book-says.html Jeff. -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of ales_75 Sent: Thursday, October 25, 2007 8:42 AM To: MbUnit.User Subject: MbUnit How to test non public metods Hi all, I'm new in TDD and Unit testing, I have a simple question. We are developing huge application and now we are thinking about automatic test of our code. If we are start "Test first" development, how can I test all my code if there are non public members of classes? We do not want to release our application with test inside our assemblies, so I think that we must have Test assemblies in which we will have Test. In release build of our application we do not ship Test assemblies. But I cannot imagine how we can write our code with "Test First" development, because all members of our classes are not public, so I cannot test them all. Can you point me to some materials where is how-to do that? Or "Test First" development is only for public members of classes? If I have to test only public classes, then most of tests will be complicated and will not describe our code well. May be that this question is stupid, but if someone can help me with it, It will be geat. Sorry for my poor english. Ales --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MbUnit.User" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/MbUnitUser?hl=en -~----------~----~----~----~------~----~------~--~---
